Created
November 16, 2021 02:33
-
-
Save steveriggins/809b606017ece133434cd28911657138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import Foundation | |
class CombineExampleBase { | |
@Published var baseValue: Int | |
init(baseValue: Int) { | |
self.baseValue = baseValue | |
} | |
} | |
final class CombineExample: CombineExampleBase { | |
@Published var blurValue: Float | |
private var cancellables = Set<AnyCancellable>() | |
init(blurValue: Float) { | |
self.blurValue = blurValue | |
super.init(baseValue: 50) | |
$blurValue | |
.sink { [weak self] value in | |
self?.displayBlur(value: value) | |
} | |
.store(in: &cancellables) | |
} | |
private func displayBlur(value: Float) { | |
print("BlueValue is: \(value)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment