Skip to content

Instantly share code, notes, and snippets.

@VAnsimov
Last active October 14, 2021 05:29
Show Gist options
  • Save VAnsimov/2c57f53ee35bf6c35157f935d11cd45a to your computer and use it in GitHub Desktop.
Save VAnsimov/2c57f53ee35bf6c35157f935d11cd45a to your computer and use it in GitHub Desktop.
// 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