forked from Reactive-Extensions/rx.angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx.angular.min.js
1 lines (1 loc) · 1.77 KB
/
rx.angular.min.js
1
(function(){function a(a){return"[object Function]"===k.call(a)}function b(){}var c={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},d=c[typeof window]&&window||this,e=c[typeof exports]&&exports&&!exports.nodeType&&exports,f=c[typeof module]&&module&&!module.nodeType&&module,g=(f&&f.exports===e&&e,c[typeof global]&&global);!g||g.global!==g&&g.window!==g||(d=g);var h=Rx.Observable,i=h.prototype,j=h.create,k={}.toString,l=Array.prototype.slice,m=angular.module("rx",[]);m.factory("rx",function(a){if(!a.Rx)throw new Error("Rx is not defined!");return a.Rx}),m.factory("observeOnScope",function(a){return function(b,c,d){return a.Observable.create(function(a){function e(b,c){a.onNext({oldValue:c,newValue:b})}return b.$watch(c,e,d)})}}),i.safeApply=function(c,d){return d=a(d)?d:b,this.doAction(function(a){c.$$phase||c.$root.$$phase?d(a):c.$apply(function(){d(a)})})},m.config(["$provide",function(a){a.decorator("$rootScope",["$delegate",function(a){return Object.defineProperties(a.constructor.prototype,{$toObservable:{value:function(a,b){var c=this;return j(function(d){function e(a,b){d.onNext({oldValue:b,newValue:a})}var f=c.$watch(a,e,b),g=Rx.Disposable.create(f);return c.$on("$destroy",function(){g.dispose()}),g})},enumerable:!1},$eventToObservable:{value:function(a){var b=this;return j(function(c){function d(){var a={event:arguments[0],additionalArguments:l.call(arguments,1)};c.onNext(a)}var e=b.$on(a,d),f=Rx.Disposable.create(e);return b.$on("$destroy",function(){f.dispose()}),f})},enumerable:!1},$createObservableFunction:{value:function(a,b){var c=this;return j(function(d){return c[a]=function(){b?d.onNext(b.apply(this,arguments)):1===arguments.length?d.onNext(arguments[0]):d.onNext(arguments)},function(){delete c[a]}})},enumerable:!1}}),a}])}])}).call(this);