Exercise - RefCount Operator
Exercise
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
Subject. - Use the
multicast()operator to create aConnectableObservable, and use therefCount()operator to track Subscription references. - Subscribe to the multicasted Observable and keep a reference to
the
Subscriptioninstance. - After 5000 milliseconds unsubscribe from the multicasted Observable.