LiveLoveApp logo

Exercise - Unicast


The goal of this exercise is to practice creating a unicast Observable.

  1. Go to, sign in, and then create a new sandbox using the "Vanilla TypeScript" template.
  2. Add the rxjs dependency.
  3. Open the index.ts file and import the Observable class from the rxjs module.
  4. Create a new Observable instance, providing the subscribe function.
  5. Use the console.log() function to log a message for each new subscription.
  6. Optionally produce a value.
  7. Return a teardown function.
  8. Subscribe to the new Observable multiple times and note the number of subscriptions.


Here is the signature for the Observable class's constructor() function:

constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic);