rxjs subscribe to observable code 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: rxjs .subscribe
content_copy
open_in_new
import { interval } from 'rxjs';
const observable = interval(1000);
const subscription = observable.subscribe(x => console.log(x));
subscription.unsubscribe();