OBSERVABLES : Angular observable definition, type of notification, subject and example

yotube
0

 Observables provide support for passing messages between publishers and subscribers in your application.

Observables offer significant benefits over other techniques for event handling, asynchronous programming, and handling multiple values.


The subscribe() call returns a Subscription object that has an unsubscribe() method, which you call to stop receiving notifications.


Three types of notifications that an observable can send:

next         Required. A handler for each delivered value. Called zero or more times after execution starts.

error        Optional. A handler for an error notification. An error halts execution of the observable instance.

complete         Optional. A handler for the execution-complete notification. Delayed values can continue to be delivered to the next handler after execution is complete.


    let s = new Subject();

s.subscribe((a)=>{
console.log(a);
})

s.next("Hi");



let myObservable = Observable.create(observer => {
observer.next("hello");
});
myObservable.subscribe((data) => {
console.log(data);
});


Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top