Last active
October 14, 2019 19:58
-
-
Save nalexn/250151190009b2806682064a26890f66 to your computer and use it in GitHub Desktop.
Article_001 https://nalexn.github.io/cancelbag-for-combine/
This file contains 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
class ValueConsumer { | |
private var subscription1: AnyCancellable? | |
private var subscription2: AnyCancellable? | |
private var subscription3: AnyCancellable? | |
private let mySubject = CurrentValueSubject<Int, Never>(0) | |
private var myVar: Int = 0 | |
func consumeValues(publisher1, ...) { | |
subscription1 = publisher1 | |
.sink { print("New value: \($0)") } | |
subscription2 = mySubject | |
.subscribe(publisher2) | |
subscription3 = publisher3 | |
.assign(to: \.myVar, on: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment