Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created April 9, 2017 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/d3b5dc6b618381d37432206a9a327952 to your computer and use it in GitHub Desktop.
Save rahulsahay19/d3b5dc6b618381d37432206a9a327952 to your computer and use it in GitHub Desktop.
main.ts
import {Observable, Observer} from "rxjs";
//Creating new Datasource using that API.
let nums = [0,1,2,3,4,5,6,7,8,9];
//Now passed this array as datasource in observable.
let dataSource = Observable.from(nums);
//Creating observer via implementing Observer interface
class customObserver implements Observer<number> {
next(value){
console.log(`Incoming Value:- ${value}`);
}
error(e){
console.log(`Error Happend:- $(e)`);
}
complete(){
console.log("We are done!!!");
}
}
//Subscribing observer
dataSource.subscribe(new customObserver());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment