LiveLoveApp logo

Exercise - Multicast

Instructions

The goal of the exercise is to use a Subject to multicast an Observable that is created from a fetch request.

  1. Open exercise on codesandbox I've already imported the necessary rxjs functions and classes for you.
  2. The user$ observable emits a next notification with the data from the REST API request.
  3. Start by subscribing to the user$ observable multiple times.
  4. Open your browser's developer tools and inspect the network requests.
  5. Comment out the multiple subscriptions to the user$ observable.
  6. Create a new userSubject$ using the Subject class.
  7. Subscribe multiple times to the userSubject$.
  8. Subscribe to the user$ observable and emit the value to the subject's Observers using the next() method.
  9. Bonus: use the Subject as the Observer.