create
signature: create(subscribe: function)
create(subscribe: function)Create an observable with given subscription function.
Examples
// RxJS v6+
import { Observable } from 'rxjs';
/*
Create an observable that emits 'Hello' and 'World' on
subscription.
*/
const hello = Observable.create(function(observer) {
observer.next('Hello');
observer.next('World');
observer.complete();
});
//output: 'Hello'...'World'
const subscribe = hello.subscribe(val => console.log(val));Additional Resources
Last updated