UNPKG

@datorama/akita-ng-effects

Version:

A Reactive State Management extension dealing with side effects.

16 lines (14 loc) 7.74 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("@datorama/akita"),require("rxjs/operators"),require("ts-action"),require("ts-action-operators")):"function"==typeof define&&define.amd?define("@datorama/akita-ng-effects",["exports","@angular/core","rxjs","@datorama/akita","rxjs/operators","ts-action","ts-action-operators"],e):e(((t=t||self).datorama=t.datorama||{},t.datorama["akita-ng-effects"]={}),t.ng.core,t.rxjs,t.akita,t.rxjs.operators,t.tsAction,t.tsActionOperators)}(this,(function(t,e,r,o,n,a,c){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};var u=function(){return(u=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.create;function f(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],o=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,a=r.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(o=a.next()).done;)c.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return c}function p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}Object.create;var l=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(r,t),r.prototype.dispatch=function(t){this.logAction(t),this.next(t)},r.prototype.logAction=function(t){var e=t.type,r=function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(r[o[n]]=t[o[n]])}return r}(t,["type"]),n=Object.getOwnPropertyNames(r).length>0;o.logAction(e,null,n?r:null)},r.ɵprov=e["ɵɵdefineInjectable"]({factory:function(){return new r},token:r,providedIn:"root"}),r.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],r}(r.Subject),d=new e.InjectionToken("@datorama/akita Internal Root Effects"),y=new e.InjectionToken("@datorama/akita Root Effects"),h=new e.InjectionToken("@datorama/akita Internal Feature Effects"),b=new e.InjectionToken("@datorama/akita Feature Effects"),v=function(){function t(t){this.actions$=t,this.effectInstanceSources=new WeakSet,this.destroyEffects$=new r.Subject}return t.prototype.subscribeToEffects=function(t){var e=this,r=function(r){var a=t[r];!0===a.isEffect&&a.pipe(n.takeUntil(o.destroyEffects$)).subscribe((function(t){e.dispatchAction(a,t)}))},o=this;for(var a in t)r(a)},t.prototype.has=function(t){return this.effectInstanceSources.has(t)},t.prototype.add=function(t){this.effectInstanceSources.add(t)},t.prototype.dispatchAction=function(t,e){t.dispatchAction&&this.checkAction(e)&&this.actions$.dispatch(e)},t.prototype.checkAction=function(t){if(t.type)return!0;throw new TypeError("Make sure to provide a valid action type or set the option {dispatch: false}")},t.prototype.ngOnDestroy=function(){this.destroyEffects$.next(),this.effectInstanceSources=new WeakSet},t.ctorParameters=function(){return[{type:l}]},t.ɵprov=e["ɵɵdefineInjectable"]({factory:function(){return new t(e["ɵɵinject"](l))},token:t,providedIn:"root"}),t.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:l}]},t}(),g=function(){function t(t,e,r,o){var n=this;this.moduleManager=t,this.actions=e,this.parentModule=o,this.rootGuard(),r.forEach((function(t){return n.moduleManager.subscribeToEffects(t)}))}return t.prototype.rootGuard=function(){if(this.parentModule)throw new Error("EffectsRootModule is already loaded. Import it in the AppModule only")},t.ctorParameters=function(){return[{type:v},{type:l},{type:Array,decorators:[{type:e.Inject,args:[y]}]},{type:t,decorators:[{type:e.Optional},{type:e.SkipSelf}]}]},t.decorators=[{type:e.NgModule}],t.ctorParameters=function(){return[{type:v},{type:l},{type:Array,decorators:[{type:e.Inject,args:[y]}]},{type:t,decorators:[{type:e.Optional},{type:e.SkipSelf}]}]},t}(),j=function(){function t(t,e){var r=this;this.moduleManager=t,e.forEach((function(t){return t.forEach((function(t){r.moduleManager.subscribeToEffects(t)}))}))}return t.ctorParameters=function(){return[{type:v},{type:Array,decorators:[{type:e.Inject,args:[b]}]}]},t.decorators=[{type:e.NgModule}],t.ctorParameters=function(){return[{type:v},{type:Array,decorators:[{type:e.Inject,args:[b]}]}]},t}(),m=function(){function t(){}return t.forRoot=function(t){return void 0===t&&(t=[]),{ngModule:g,providers:[v,l,t,{provide:d,useValue:[t]},{provide:y,useFactory:O,deps:[e.Injector,d,v]}]}},t.forFeature=function(t){return void 0===t&&(t=[]),{ngModule:j,providers:[t,{provide:h,useValue:t,multi:!0},{provide:b,multi:!0,useFactory:O,deps:[e.Injector,h,v]}]}},t.decorators=[{type:e.NgModule,args:[{}]}],t}();function O(t,e,r){var o,n,a=[];try{for(var c=f(e),i=c.next();!i.done;i=c.next()){var u=i.value;a.push.apply(a,p(u))}}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.error}}return a.reduce((function(e,o){return r.has(o)||(r.add(o),e.push(t.get(o))),e}),[])}function w(t,e,r){Object.defineProperty(t,"isEffect",{enumerable:!0,configurable:!1,writable:!1,value:!0}),Object.defineProperty(t,"name",{enumerable:!0,configurable:!1,writable:!1,value:e}),Object.defineProperty(t,"dispatchAction",{enumerable:!0,configurable:!1,writable:!1,value:r.dispatch})}Object.defineProperty(t,"createAction",{enumerable:!0,get:function(){return a.action}}),Object.defineProperty(t,"payload",{enumerable:!0,get:function(){return a.payload}}),Object.defineProperty(t,"props",{enumerable:!0,get:function(){return a.props}}),Object.defineProperty(t,"ofType",{enumerable:!0,get:function(){return c.ofType}}),t.Actions=l,t.AkitaNgEffectsModule=m,t.Effect=function(t){return t=u({dispatch:!1},t),function(e,r){var o;Object.defineProperty(e,r,{get:function(){return o},set:function(e){w(e,r,t),o=e},enumerable:!0})}},t.EffectsRootModule=g,t.createEffect=function(t,e){var r=t();return w(r,null,e=u({dispatch:!1},e)),r},t.ɵa=O,t.ɵb=d,t.ɵc=y,t.ɵd=h,t.ɵe=b,t.ɵf=v,t.ɵg=j,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=datorama-akita-ng-effects.umd.min.js.map