Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
RxJs: Adapt jQuery.getJSON to an Rx.Observable
function getJSON(url, data) {
return Rx.Observable.create(observer => {
var canceled = false;
if (!canceled) {
jQuery.getJSON(url, data).
done(data => {
fail(err => observer.onError(err));
return () => canceled = true;
getJSON('', { format: 'json' }).forEach(e => console.log(e));
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.