Skip to content

Instantly share code, notes, and snippets.

@hustshawn
Created December 8, 2016 13:27
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 hustshawn/1c4c994e3de0afd1b7490618825f470a to your computer and use it in GitHub Desktop.
Save hustshawn/1c4c994e3de0afd1b7490618825f470a to your computer and use it in GitHub Desktop.
It shows how Observable in RxJS works.
let o = new Observable(observer => {
const token = doAsyncThing((err, value) => {
if (err) {
observer.error(err);
} else {
observer.next(value);
observer.complete();
}
});
return () => {
cancelAsyncThing(token);
};
});
@hustshawn
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment