refreshButton = document.querySelector('.refresh'); var refreshClickStream = Rx.Observable.fromEvent(refreshButton, 'click'); // [*] Create a normal Observable ! var observable = Rx.Observable.create(function subscribe(observer) { var id = setInterval(() => { observer.next('hi') }, 1000); }); // [*] Create a normal Observable From array of values! Rx.Observable.from([1,2,3]); JS Showing a How we can create Observables in different manners Different manner to different observables
observer = { next: x => console.log('Observer got a next value: ' + x), error: err => console.error('Observer got an error: ' + err), complete: () => console.log('Observer got a complete notification'), }; JS Showing a How we can create observers PS: You can pass them the callback without observers attachments .. JS
observable = Rx.Observable.interval(1000); var subscription = observable.subscribe(x => console.log(x)); // Later: // This cancels the ongoing Observable execution which // was started by calling subscribe with an Observer. subscription.unsubscribe(); JS Showing a How we can work with subscription PS: You can pass compose and unsubscribe observables JS