Last active
October 14, 2021 05:29
-
-
Save VAnsimov/2c57f53ee35bf6c35157f935d11cd45a to your computer and use it in GitHub Desktop.
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
// 1 | |
final class MVIContainer<Intent, Model>: ObservableObject { | |
// 2 | |
let intent: Intent | |
let model: Model | |
private var cancellable: Set<AnyCancellable> = [] | |
init(intent: Intent, model: Model, modelChangePublisher: ObjectWillChangePublisher) { | |
self.intent = intent | |
self.model = model | |
// 3 | |
modelChangePublisher | |
.receive(on: RunLoop.main) | |
.sink(receiveValue: objectWillChange.send) | |
.store(in: &cancellable) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment