mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-24 14:02:53 +01:00
Cleanup debounce
This commit is contained in:
parent
14e91a680e
commit
ab51d57648
@ -14,31 +14,33 @@ class DisplaySettingsLocalValues: ObservableObject {
|
||||
@Published var lineSpacing = Theme.shared.lineSpacing
|
||||
@Published var fontSizeScale = Theme.shared.fontSizeScale
|
||||
|
||||
private let debouncesDelay: DispatchQueue.SchedulerTimeType.Stride = .seconds(0.5)
|
||||
|
||||
private var subscriptions = Set<AnyCancellable>()
|
||||
|
||||
init() {
|
||||
$tintColor
|
||||
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.main)
|
||||
.debounce(for: debouncesDelay, scheduler: DispatchQueue.main)
|
||||
.sink(receiveValue: { newColor in Theme.shared.tintColor = newColor })
|
||||
.store(in: &subscriptions)
|
||||
$primaryBackgroundColor
|
||||
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.main)
|
||||
.debounce(for: debouncesDelay, scheduler: DispatchQueue.main)
|
||||
.sink(receiveValue: { newColor in Theme.shared.primaryBackgroundColor = newColor })
|
||||
.store(in: &subscriptions)
|
||||
$secondaryBackgroundColor
|
||||
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.main)
|
||||
.debounce(for: debouncesDelay, scheduler: DispatchQueue.main)
|
||||
.sink(receiveValue: { newColor in Theme.shared.secondaryBackgroundColor = newColor })
|
||||
.store(in: &subscriptions)
|
||||
$labelColor
|
||||
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.main)
|
||||
.debounce(for: debouncesDelay, scheduler: DispatchQueue.main)
|
||||
.sink(receiveValue: { newColor in Theme.shared.labelColor = newColor })
|
||||
.store(in: &subscriptions)
|
||||
$lineSpacing
|
||||
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.main)
|
||||
.debounce(for: debouncesDelay, scheduler: DispatchQueue.main)
|
||||
.sink(receiveValue: { newSpacing in Theme.shared.lineSpacing = newSpacing })
|
||||
.store(in: &subscriptions)
|
||||
$fontSizeScale
|
||||
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.main)
|
||||
.debounce(for: debouncesDelay, scheduler: DispatchQueue.main)
|
||||
.sink(receiveValue: { newScale in Theme.shared.fontSizeScale = newScale })
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user