You should have a read of these couple of posts first:
- 16 Ways to Create IObservables without implementing IObservable
To take it a step further from the brief code snippets shown in the blog posts by Matthew Podwysocki above, here’s a quick demo on how you can create multiple observable sequences of values and have multiple observers observe them.
So first, a simple set of HTML to create a couple of spans:
The key things to note here are the two ways you can create an observer, either explicitly using the Rx.Observer.Create function or creating one dynamically using one of the overloaded Subscribe functions on an observable sequence.
When you call Subscribe on an observable, you get back a disposable object which can then be used to unsubscribe an observer from an ongoing observable sequence (see line 50 in the code above and the demo below).
Subscribe to my newsletter and get new contents delivered straight to your inbox :-)