So I'm getting started with Combine, and I want to have a component which publishes events like a simple event emitter.
So in other words, I want to have a model like this (pseudocode):
class MyModel {
var onNewEvent: EventPublisher
func foo(bar: Bar) {
onNewEvent.publish(Event(bar))
}
}
let model: MyModel...
model.onNewEvent.sink(
receiveValue: { event in print(event) }
)
I can achieve something like this using a notification center publisher, but I want to avoid this unnecessary step if possible.
Is there such a thing as a simple publisher which just publishes values on command, or else what would be the idiomatic way to handle this in combine?