Skip to content

Instantly share code, notes, and snippets.

@wKoza wKoza/observer.ts Secret
Last active May 22, 2017

Embed
What would you like to do?
import {Observable} frpm 'rxjs/Observable';
import 'rxjs/Rx';
const myObservable = new Observable((observer) => {
const datasource = new DataSource();
datasource.ondata = (e) => observer.next(e);
datasource.onerror = (err) => observer.error(err);
datasource.oncomplete = () => observer.complete();
return () => {
datasource.destroy();
};
});
myObservable.subscribe(value => { console.log(value) },
error => { console.log(error) },
() => { console.log('fin') }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.