What is subscribing?
An Observable instance begins publishing values only when someone subscribes to it. So you need to subscribe by calling the subscribe() method of the instance, passing an observer object to receive the notifications.
Let's take an example of creating and subscribing to a simple observable, with an observer that logs the received message to the console.
Creates an observable sequence of 5 integers, starting from 1const source = range(1, 5);// Create observer objectconst myObserver = {next: x => console.log('Observer got a next value: ' + x),error: err => console.error('Observer got an error: ' + err),complete: () => console.log('Observer got a complete notification'),};// Execute with the observer object and Prints out each itemsource.subscribe(myObserver);// => Observer got a next value: 1// => Observer got a next value: 2// => Observer got a next value: 3// => Observer got a next value: 4// => Observer got a next value: 5// => Observer got a complete notification
April 09, 2022
491
Read more
What is Angular Framework?
November 04, 2022
AngularWhat is a Angular module?
November 03, 2022
AngularWhat are the steps to use animation module?
October 31, 2022
Angular