From 38115a28278d292bf4da692c7fa02de4ea9c19fd Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Mon, 15 Aug 2022 21:29:16 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Refactor=20to=20non?= =?UTF-8?q?=20stored=20property,=20to=20avoid=20duplicate=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GradientActivityIndicatorViewModel.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift index 01dfc05..50390d6 100644 --- a/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift +++ b/GradientLoadingBar/Feature/GradientActivityIndicatorView/GradientActivityIndicatorViewModel.swift @@ -73,10 +73,9 @@ final class GradientActivityIndicatorViewModel { /// /// - Note: We explicitly have to pass this value through the view-model, in order to restart the animation when this value changes /// while the loading bar is visible. - var progressAnimationDuration: TimeInterval = .GradientLoadingBar.progressDuration { - didSet { - gradientLayerAnimationDurationSubject.value = progressAnimationDuration - } + var progressAnimationDuration: TimeInterval { + get { gradientLayerAnimationDurationSubject.value } + set { gradientLayerAnimationDurationSubject.value = newValue } } // MARK: - Private properties @@ -94,7 +93,7 @@ final class GradientActivityIndicatorViewModel { init() { gradientLayerColorsSubject = Variable(gradientColors.infiniteGradientColors().map(\.cgColor)) - gradientLayerAnimationDurationSubject = Variable(progressAnimationDuration) + gradientLayerAnimationDurationSubject = Variable(.GradientLoadingBar.progressDuration) gradientLayerAnimationDuration.subscribe { [weak self] _, _ in self?.restartAnimationIfNeeded()