creating observables in rxjs 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 create observable from value
import { of } from 'rxjs';
const value$ = of(1);
Example 3: create an observabloe js
content_copy
open_in_new
function foo() {
console.log('Hello');
return 42;
}
const x = foo.call();
console.log(x);
const y = foo.call();
console.log(y);