Exercise - Multicast
Instructions
The goal of the exercise is to use a Subject
to multicast an Observable that is created from a fetch request.
- Open exercise on codesandbox I've already imported the necessary rxjs functions and classes for you.
- The
user$
observable emits a next notification with thedata
from the REST API request. - Start by subscribing to the
user$
observable multiple times. - Open your browser's developer tools and inspect the network requests.
- Comment out the multiple subscriptions to the
user$
observable. - Create a new
userSubject$
using theSubject
class. - Subscribe multiple times to the
userSubject$
. - Subscribe to the
user$
observable and emit the value to the subject's Observers using thenext()
method. - Bonus: use the
Subject
as theObserver
.