ReactiveUI has a bunch of different ways to create IObservable
s from existing sources, such as another IObservable
, an IEnumerable
, an event
, etc, but as near as I can tell it doesn't have any way to actually originate one, which you would think should be the simplest possible case!
It seems obvious that there should be a built-in way to create an object that implements IObservable<T>
, with some sort of SetNewValue(T value)
method that you can call to push a new value out to all the subscribers. But I don't see it, either in the documentation or in Intellisense.
I know this could be worked around with Observable.FromEvent
, but that feels like a hack. I'm not looking for an event
; I'm looking for an object. Am I missing something? Does this exist and I just don't know what to look for, or is the FromEvent
workaround the best thing I'm gonna find?
This is called a Subject (or PublishSubject in other languages' implementation of Rx), and it does exactly what you describe!