Skip to content

Instantly share code, notes, and snippets.

@Ibro
Last active April 26, 2017 04:55
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 Ibro/a17382d5c3b520f7a2a2b19b70743e0d to your computer and use it in GitHub Desktop.
Save Ibro/a17382d5c3b520f7a2a2b19b70743e0d to your computer and use it in GitHub Desktop.
Implementing simple observer for observable - Coding Blast - www.codingblast.com
import { Observable, Observer } from 'rxjs';
let words = ['coding blast', 'coding', 'blast'];
let source = Observable.from(words);
class SimpleObserver implements Observer<string> {
next(value: string) {
console.log('next: ', value);
}
error(err: any) {
console.log('error: ', err);
}
complete() {
console.log('complete');
}
}
let observer = new SimpleObserver();
source.subscribe(observer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment