RxJS-fruits

โ—€Level 1 of 16โ–พโ–ถ

Exercise: subscribe

Welcome to RxJS-fruits, where you write JavaScript / TypeScript code to mix your fruit juice!

The basis of Reactive Extensions is the Observable. It is a counterpart of an array. Instead of that Retaining data it streams the data to interested subscribers. (More information about the Observable)

An Observable is therefore only active if it is subscribed to with the subscribe-function. (More information about Subscription)

        
  const observable = new Observable(subscriber => {
    subscriber.next(1);
    subscriber.next(2);
    subscriber.next(3);
  }).subscribe(x => console.log(x));

  // Logs:
  // 1
  // 2
  // 3
  
    
        
observable.subscribe();
  
    

๐Ÿงพ Recipe

In the source code we have an empty Observable with no data to expect.

Move the conveyor belt, by subscribing to the empty Observable with the subscribe function and click on the start button.

Made with โค by Gregor Biswanger โ€ข GitHub โ€ข Twitter โ€ข Graphics by Bele EisenmannEnglishPrivacy
sound-icon
By continuing your visit to this site, you accept the use of cookies by Google Analytics to collect visitor statistics. More information