Exercise - RefCount Operator
The goal of this exercise is to create a multicasted Observable that is referenced counted, avoiding the need to connect when there are more than one Observer and unsubscribe when there are no longer any Observers.
- Open exercise on codesandbox. I've already imported the necessary rxjs functions and classes for you.
- Create a new
- Use the
multicast()operator to create a
ConnectableObservable, and use the
refCount()operator to track Subscription references.
- Subscribe to the multicasted Observable and keep a reference to
- After 5000 milliseconds unsubscribe from the multicasted Observable.