Skip to content

Instantly share code, notes, and snippets.

@Ibro
Last active April 26, 2017 04:54
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/3fb95c61cbc308660f0ed993c2d099f6 to your computer and use it in GitHub Desktop.
Save Ibro/3fb95c61cbc308660f0ed993c2d099f6 to your computer and use it in GitHub Desktop.
Simple observer create and multiple subscribers - Coding Blast - www.codingblast.com
import {Observable} from 'rxjs';
let words = ['coding blast', 'coding', 'blast'];
let source = Observable.create(observer => {
for (let word of words) {
observer.next(word);
}
observer.complete();
});
let subscriberA = {
next(value: any) {
console.log('Subscriber A - next: ', value);
},
complete() {
console.log('Subscriber A - complete');
}
};
let subscriberB = {
next(value: any) {
console.log('Subscriber B - next: ', value);
},
complete() {
console.log('Subscriber B - complete');
}
};
source.subscribe(subscriberA);
source.subscribe(subscriberB);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment