RxJS Observable example
Example 1: understanding Observable.create(
import { Observable } from "rxjs/Observable";
var observable = Observable.create(function subscribe(observer) {
observer.next('Hey guys!')
})
var observable = Observable.create((observer:any) => {
observer.next('Hey guys!')
})
Example 2: emit new value observable
const observable = new BehaviorSubject("initial value");
observable.subscribe({
next: (value) => console.log("The value is: ", value)
});
observable.next("a new value");
Example 3: rxjs create observable from value
import { of } from 'rxjs';
const value$ = of(1);