Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created January 15, 2015 21: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 mattpodwysocki/45fcfd134d3c7126e98f to your computer and use it in GitHub Desktop.
Save mattpodwysocki/45fcfd134d3c7126e98f to your computer and use it in GitHub Desktop.
// Using anon functions
var source = self;
return new AnonymousObservable(function (o) {
return source.subscribe(
function (x) { o.onNext(x); },
function (e) { o.onError(e); },
function () { o.onCompleted(); })
});
// Using binders
function bindOnNext(o) {
return function (x) { o.onNext(x); };
}
function bindOnError(o) {
return function (e) { o.onError(e); };
}
function bindOnCompleted(o) {
return function () { o.onCompleted(); };
}
// Using anon functions
var source = self;
return new AnonymousObservable(function (o) {
return source.subscribe(
bindOnNext(o),
bindOnError(o),
bindOnCompleted(o))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment