Created
May 29, 2015 09:26
-
-
Save Willmo36/87cb6583950fed3b72f1 to your computer and use it in GitHub Desktop.
Angular Rx safeSubscribe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rx.Observable.prototype.safeSubscribe = function(scope, fn, err, cmp) { | |
var disposable = this.safeApply(scope, fn).subscribe(angular.noop, err, cmp); | |
scope.$on("$destroy", function() { | |
disposable.dispose(); | |
}); | |
return disposable; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment