LiveLoveApp logo

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.

  1. Open exercise on codesandbox. I've already imported the necessary rxjs functions and classes for you.
  2. Create a new Subject.
  3. Use the multicast() operator to create a ConnectableObservable, and use the refCount() operator to track Subscription references.
  4. Subscribe to the multicasted Observable and keep a reference to the Subscription instance.
  5. After 5000 milliseconds unsubscribe from the multicasted Observable.