@storeon/angular
Advanced tools
Comparing version 0.2.0 to 0.3.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators'), require('@angular/core')) : | ||
typeof define === 'function' && define.amd ? define('@storeon/angular', ['exports', 'rxjs', 'rxjs/operators', '@angular/core'], factory) : | ||
(factory((global.storeon = global.storeon || {}, global.storeon.angular = {}),global.rxjs,global.rxjs.operators,global.ng.core)); | ||
}(this, (function (exports,rxjs,operators,i0) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('storeon')) : | ||
typeof define === 'function' && define.amd ? define('@storeon/angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', 'storeon'], factory) : | ||
(global = global || self, factory((global.storeon = global.storeon || {}, global.storeon.angular = {}), global.ng.core, global.rxjs, global.rxjs.operators)); | ||
}(this, function (exports, core, rxjs, operators) { 'use strict'; | ||
@@ -21,9 +21,8 @@ /*! ***************************************************************************** | ||
***************************************************************************** */ | ||
var __assign = function () { | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
@@ -40,3 +39,3 @@ return t; | ||
/** @type {?} */ | ||
var STOREON = new i0.InjectionToken('Token for store object'); | ||
var STOREON = new core.InjectionToken('Token for store object'); | ||
@@ -48,3 +47,3 @@ /** | ||
/** | ||
* @template State | ||
* @template State, Events | ||
*/ | ||
@@ -56,7 +55,8 @@ var StoreonService = /** @class */ (function () { | ||
this.state$ = new rxjs.BehaviorSubject(this.store.get()); | ||
this.unbind = this.store.on('@changed', ( /** | ||
this.unbind = this.store.on('@changed', (/** | ||
* @param {?} state | ||
* @return {?} | ||
*/function (state) { | ||
_this.state$.next(__assign({}, ( /** @type {?} */(state)))); | ||
*/ | ||
function (state) { | ||
_this.state$.next(__assign({}, (/** @type {?} */ (state)))); | ||
return null; | ||
@@ -73,21 +73,23 @@ })); | ||
*/ | ||
function (pathOrMapFn) { | ||
/** @type {?} */ | ||
var mapped$; | ||
if (typeof pathOrMapFn === 'string') { | ||
mapped$ = this.state$.pipe(operators.pluck(pathOrMapFn)); | ||
} | ||
else if (typeof pathOrMapFn === 'function') { | ||
mapped$ = this.state$.pipe(operators.map(( /** | ||
* @param {?} source | ||
* @return {?} | ||
*/function (source) { return pathOrMapFn(source); }))); | ||
} | ||
else { | ||
throw new TypeError("Unexpected type '" + typeof pathOrMapFn + "' in select operator," + | ||
" expected 'string' or 'function'"); | ||
} | ||
return mapped$.pipe(operators.distinctUntilChanged()); | ||
}; | ||
function (pathOrMapFn) { | ||
/** @type {?} */ | ||
var mapped$; | ||
if (typeof pathOrMapFn === 'string') { | ||
mapped$ = this.state$.pipe(operators.pluck(pathOrMapFn)); | ||
} | ||
else if (typeof pathOrMapFn === 'function') { | ||
mapped$ = this.state$.pipe(operators.map((/** | ||
* @param {?} source | ||
* @return {?} | ||
*/ | ||
function (source) { return pathOrMapFn(source); }))); | ||
} | ||
else { | ||
throw new TypeError("Unexpected type '" + typeof pathOrMapFn + "' in select operator," + | ||
" expected 'string' or 'function'"); | ||
} | ||
return mapped$.pipe(operators.distinctUntilChanged()); | ||
}; | ||
/** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -98,2 +100,3 @@ * @param {?=} data | ||
StoreonService.prototype.dispatch = /** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -103,5 +106,5 @@ * @param {?=} data | ||
*/ | ||
function (event, data) { | ||
this.store.dispatch(event, data); | ||
}; | ||
function (event, data) { | ||
this.store.dispatch(event, data); | ||
}; | ||
/** | ||
@@ -113,9 +116,9 @@ * @return {?} | ||
*/ | ||
function () { | ||
if (this.unbind) { | ||
this.unbind(); | ||
} | ||
}; | ||
function () { | ||
if (this.unbind) { | ||
this.unbind(); | ||
} | ||
}; | ||
StoreonService.decorators = [ | ||
{ type: i0.Injectable, args: [{ | ||
{ type: core.Injectable, args: [{ | ||
providedIn: 'root' | ||
@@ -125,8 +128,6 @@ },] } | ||
/** @nocollapse */ | ||
StoreonService.ctorParameters = function () { | ||
return [ | ||
{ type: undefined, decorators: [{ type: i0.Inject, args: [STOREON,] }] } | ||
]; | ||
}; | ||
/** @nocollapse */ StoreonService.ngInjectableDef = i0.defineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(i0.inject(STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
StoreonService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [STOREON,] }] } | ||
]; }; | ||
/** @nocollapse */ StoreonService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(core.ɵɵinject(STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
return StoreonService; | ||
@@ -139,34 +140,48 @@ }()); | ||
*/ | ||
var StoreonModule = /** @class */ (function () { | ||
function StoreonModule() { | ||
} | ||
StoreonModule.decorators = [ | ||
{ type: i0.NgModule, args: [{ | ||
declarations: [], | ||
imports: [], | ||
providers: [], | ||
exports: [] | ||
},] } | ||
]; | ||
return StoreonModule; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
* | ||
* | ||
* Experimental feature, works only with Ivy renderer | ||
* Patches the component with keys from storeon store | ||
* | ||
* @template State, Events | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function UseStoreon(config) { | ||
return (/** | ||
* @param {?} cmpType | ||
* @return {?} | ||
*/ | ||
function (cmpType) { | ||
/** @type {?} */ | ||
var originalFactory = cmpType.ngComponentDef.factory; | ||
cmpType.ngComponentDef.factory = (/** | ||
* @return {?} | ||
*/ | ||
function () { | ||
/** @type {?} */ | ||
var cmp = originalFactory(cmpType.ngComponentDef.type); | ||
/** @type {?} */ | ||
var storeon = core.ɵɵdirectiveInject(StoreonService); | ||
config.keys.forEach((/** | ||
* @param {?} key | ||
* @return {?} | ||
*/ | ||
function (key) { return cmp[key] = storeon.useStoreon(key); })); | ||
if (config.dispatcher) { | ||
cmp[config.dispatcher] = storeon.dispatch.bind(storeon); | ||
} | ||
return cmp; | ||
}); | ||
}); | ||
} | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
exports.STOREON = STOREON; | ||
exports.StoreonService = StoreonService; | ||
exports.StoreonModule = StoreonModule; | ||
exports.STOREON = STOREON; | ||
exports.UseStoreon = UseStoreon; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=storeon-angular.umd.js.map | ||
})); | ||
//# sourceMappingURL=storeon-angular.umd.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators"),require("@angular/core")):"function"==typeof define&&define.amd?define("@storeon/angular",["exports","rxjs","rxjs/operators","@angular/core"],t):t((e.storeon=e.storeon||{},e.storeon.angular={}),e.rxjs,e.rxjs.operators,e.ng.core)}(this,function(e,r,o,t){"use strict";var n=function(){return(n=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},i=new t.InjectionToken("Token for store object"),s=(a.prototype.useStoreon=function(t){var e;if("string"==typeof t)e=this.state$.pipe(o.pluck(t));else{if("function"!=typeof t)throw new TypeError("Unexpected type '"+typeof t+"' in select operator, expected 'string' or 'function'");e=this.state$.pipe(o.map(function(e){return t(e)}))}return e.pipe(o.distinctUntilChanged())},a.prototype.dispatch=function(e,t){this.store.dispatch(e,t)},a.prototype.ngOnDestroy=function(){this.unbind&&this.unbind()},a.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],a.ctorParameters=function(){return[{type:undefined,decorators:[{type:t.Inject,args:[i]}]}]},a.ngInjectableDef=t.defineInjectable({factory:function(){return new a(t.inject(i))},token:a,providedIn:"root"}),a);function a(e){var t=this;this.store=e,this.state$=new r.BehaviorSubject(this.store.get()),this.unbind=this.store.on("@changed",function(e){return t.state$.next(n({},e)),null})}var c=(p.decorators=[{type:t.NgModule,args:[{declarations:[],imports:[],providers:[],exports:[]}]}],p);function p(){}e.StoreonService=s,e.StoreonModule=c,e.STOREON=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("storeon")):"function"==typeof define&&define.amd?define("@storeon/angular",["exports","@angular/core","rxjs","rxjs/operators","storeon"],t):t(((e=e||self).storeon=e.storeon||{},e.storeon.angular={}),e.ng.core,e.rxjs,e.rxjs.operators)}(this,function(e,t,n,r){"use strict";var o=function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},i=new t.InjectionToken("Token for store object"),s=function(){function e(e){var t=this;this.store=e,this.state$=new n.BehaviorSubject(this.store.get()),this.unbind=this.store.on("@changed",function(e){return t.state$.next(o({},e)),null})}return e.prototype.useStoreon=function(e){var t;if("string"==typeof e)t=this.state$.pipe(r.pluck(e));else{if("function"!=typeof e)throw new TypeError("Unexpected type '"+typeof e+"' in select operator, expected 'string' or 'function'");t=this.state$.pipe(r.map(function(t){return e(t)}))}return t.pipe(r.distinctUntilChanged())},e.prototype.dispatch=function(e,t){this.store.dispatch(e,t)},e.prototype.ngOnDestroy=function(){this.unbind&&this.unbind()},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:undefined,decorators:[{type:t.Inject,args:[i]}]}]},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(i))},token:e,providedIn:"root"}),e}();e.STOREON=i,e.StoreonService=s,e.UseStoreon=function(e){return function(n){var r=n.ngComponentDef.factory;n.ngComponentDef.factory=function(){var o=r(n.ngComponentDef.type),i=t.ɵɵdirectiveInject(s);return e.keys.forEach(function(e){return o[e]=i.useStoreon(e)}),e.dispatcher&&(o[e.dispatcher]=i.dispatch.bind(i)),o}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=storeon-angular.umd.min.js.map |
@@ -6,10 +6,10 @@ /** | ||
import { Injectable, Inject } from '@angular/core'; | ||
import * as createStore from 'storeon'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { distinctUntilChanged, map, pluck } from 'rxjs/operators'; | ||
import createStore from 'storeon'; | ||
import { STOREON } from './storeon.token'; | ||
import { distinctUntilChanged, map, pluck } from 'rxjs/operators'; | ||
import * as i0 from "@angular/core"; | ||
import * as i1 from "./storeon.token"; | ||
/** | ||
* @template State | ||
* @template State, Events | ||
*/ | ||
@@ -56,2 +56,3 @@ export class StoreonService { | ||
/** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -82,3 +83,3 @@ * @param {?=} data | ||
]; | ||
/** @nocollapse */ StoreonService.ngInjectableDef = i0.defineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(i0.inject(i1.STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
/** @nocollapse */ StoreonService.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(i0.ɵɵinject(i1.STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
if (false) { | ||
@@ -101,2 +102,2 @@ /** | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6Im5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B7XG4gICAgICBtYXBwZWQkID0gdGhpcy5zdGF0ZSQucGlwZShwbHVjayhwYXRoT3JNYXBGbikpO1xuICAgIH0gZWxzZSBpZiAodHlwZW9mIHBhdGhPck1hcEZuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICBtYXBwZWQkID0gdGhpcy5zdGF0ZSQucGlwZShcbiAgICAgICAgbWFwKHNvdXJjZSA9PiBwYXRoT3JNYXBGbihzb3VyY2UpKVxuICAgICAgKTtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihcbiAgICAgICAgYFVuZXhwZWN0ZWQgdHlwZSAnJHt0eXBlb2YgcGF0aE9yTWFwRm59JyBpbiBzZWxlY3Qgb3BlcmF0b3IsYCArXG4gICAgICAgIGAgZXhwZWN0ZWQgJ3N0cmluZycgb3IgJ2Z1bmN0aW9uJ2BcbiAgICAgICk7XG4gICAgfVxuXG4gICAgcmV0dXJuIG1hcHBlZCQucGlwZShkaXN0aW5jdFVudGlsQ2hhbmdlZCgpKTtcbiAgfVxuXG4gIGRpc3BhdGNoPEUgZXh0ZW5kcyBFdmVudHMsIEsgZXh0ZW5kcyBrZXlvZiBFPihldmVudDogSywgZGF0YT86IEVbS10pIHtcbiAgICB0aGlzLnN0b3JlLmRpc3BhdGNoKGV2ZW50LCBkYXRhKTtcbiAgfVxuXG4gIG5nT25EZXN0cm95KCk6IHZvaWQge1xuICAgIGlmICh0aGlzLnVuYmluZCkge1xuICAgICAgdGhpcy51bmJpbmQoKTtcbiAgICB9XG4gIH1cblxufVxuIl19 |
@@ -9,4 +9,4 @@ /** | ||
export { StoreonService } from './lib/storeon.service'; | ||
export { StoreonModule } from './lib/storeon.module'; | ||
export { STOREON } from './lib/storeon.token'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSwrQkFBYyx1QkFBdUIsQ0FBQztBQUN0Qyw4QkFBYyxzQkFBc0IsQ0FBQztBQUNyQyx3QkFBYyxxQkFBcUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgQHN0b3Jlb24vYW5ndWxhclxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL3N0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLnRva2VuJztcbiJdfQ== | ||
export { UseStoreon } from './lib/storeon.decorator'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSwrQkFBYyx1QkFBdUIsQ0FBQztBQUN0Qyx3QkFBYyxxQkFBcUIsQ0FBQztBQUNwQywyQkFBYyx5QkFBeUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgQHN0b3Jlb24vYW5ndWxhclxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL3N0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLnRva2VuJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3N0b3Jlb24uZGVjb3JhdG9yJztcbiJdfQ== |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export { StoreonService, StoreonModule, STOREON } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsdURBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19 | ||
export { StoreonService, STOREON, UseStoreon } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsb0RBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19 |
@@ -7,10 +7,10 @@ /** | ||
import { Injectable, Inject } from '@angular/core'; | ||
import * as createStore from 'storeon'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { distinctUntilChanged, map, pluck } from 'rxjs/operators'; | ||
import createStore from 'storeon'; | ||
import { STOREON } from './storeon.token'; | ||
import { distinctUntilChanged, map, pluck } from 'rxjs/operators'; | ||
import * as i0 from "@angular/core"; | ||
import * as i1 from "./storeon.token"; | ||
/** | ||
* @template State | ||
* @template State, Events | ||
*/ | ||
@@ -59,2 +59,3 @@ var StoreonService = /** @class */ (function () { | ||
/** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -65,2 +66,3 @@ * @param {?=} data | ||
StoreonService.prototype.dispatch = /** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -93,3 +95,3 @@ * @param {?=} data | ||
]; }; | ||
/** @nocollapse */ StoreonService.ngInjectableDef = i0.defineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(i0.inject(i1.STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
/** @nocollapse */ StoreonService.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(i0.ɵɵinject(i1.STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
return StoreonService; | ||
@@ -115,2 +117,2 @@ }()); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbImxpYi9zdG9yZW9uLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBYSxNQUFNLGVBQWUsQ0FBQztBQUM5RCxPQUFPLEtBQUssV0FBVyxNQUFNLFNBQVMsQ0FBQztBQUN2QyxPQUFPLEVBQUUsZUFBZSxFQUFjLE1BQU0sTUFBTSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMxQyxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsR0FBRyxFQUFFLEtBQUssRUFBRSxNQUFNLGdCQUFnQixDQUFDOzs7Ozs7QUFFbEU7SUFTRSx3QkFBcUMsS0FBK0I7UUFBcEUsaUJBTUM7UUFOb0Ms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W5leHBlY3RlZCB0eXBlICcke3R5cGVvZiBwYXRoT3JNYXBGbn0nIGluIHNlbGVjdCBvcGVyYXRvcixgICtcbiAgICAgICAgYCBleHBlY3RlZCAnc3RyaW5nJyBvciAnZnVuY3Rpb24nYFxuICAgICAgKTtcbiAgICB9XG5cbiAgICByZXR1cm4gbWFwcGVkJC5waXBlKGRpc3RpbmN0VW50aWxDaGFuZ2VkKCkpO1xuICB9XG5cbiAgZGlzcGF0Y2g8RSBleHRlbmRzIEV2ZW50cywgSyBleHRlbmRzIGtleW9mIEU+KGV2ZW50OiBLLCBkYXRhPzogRVtLXSkge1xuICAgIHRoaXMuc3RvcmUuZGlzcGF0Y2goZXZlbnQsIGRhdGEpO1xuICB9XG5cbiAgbmdPbkRlc3Ryb3koKTogdm9pZCB7XG4gICAgaWYgKHRoaXMudW5iaW5kKSB7XG4gICAgICB0aGlzLnVuYmluZCgpO1xuICAgIH1cbiAgfVxuXG59XG4iXX0= |
@@ -9,4 +9,4 @@ /** | ||
export { StoreonService } from './lib/storeon.service'; | ||
export { StoreonModule } from './lib/storeon.module'; | ||
export { STOREON } from './lib/storeon.token'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSwrQkFBYyx1QkFBdUIsQ0FBQztBQUN0Qyw4QkFBYyxzQkFBc0IsQ0FBQztBQUNyQyx3QkFBYyxxQkFBcUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgQHN0b3Jlb24vYW5ndWxhclxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL3N0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLnRva2VuJztcbiJdfQ== | ||
export { UseStoreon } from './lib/storeon.decorator'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSwrQkFBYyx1QkFBdUIsQ0FBQztBQUN0Qyx3QkFBYyxxQkFBcUIsQ0FBQztBQUNwQywyQkFBYyx5QkFBeUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgQHN0b3Jlb24vYW5ndWxhclxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL3N0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLnRva2VuJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3N0b3Jlb24uZGVjb3JhdG9yJztcbiJdfQ== |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export { StoreonService, StoreonModule, STOREON } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsdURBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19 | ||
export { StoreonService, STOREON, UseStoreon } from './public_api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsb0RBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19 |
@@ -0,5 +1,5 @@ | ||
import { InjectionToken, Injectable, Inject, ɵɵdefineInjectable, ɵɵinject, ɵɵdirectiveInject } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { pluck, map, distinctUntilChanged } from 'rxjs/operators'; | ||
import 'storeon'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { distinctUntilChanged, map, pluck } from 'rxjs/operators'; | ||
import { InjectionToken, Injectable, Inject, NgModule, defineInjectable, inject } from '@angular/core'; | ||
@@ -18,3 +18,3 @@ /** | ||
/** | ||
* @template State | ||
* @template State, Events | ||
*/ | ||
@@ -61,2 +61,3 @@ class StoreonService { | ||
/** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -87,3 +88,3 @@ * @param {?=} data | ||
]; | ||
/** @nocollapse */ StoreonService.ngInjectableDef = defineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(inject(STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
/** @nocollapse */ StoreonService.ngInjectableDef = ɵɵdefineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(ɵɵinject(STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
@@ -94,25 +95,42 @@ /** | ||
*/ | ||
class StoreonModule { | ||
} | ||
StoreonModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [], | ||
imports: [], | ||
providers: [], | ||
exports: [] | ||
},] } | ||
]; | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
* | ||
* | ||
* Experimental feature, works only with Ivy renderer | ||
* Patches the component with keys from storeon store | ||
* | ||
* @template State, Events | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function UseStoreon(config) { | ||
return (/** | ||
* @param {?} cmpType | ||
* @return {?} | ||
*/ | ||
(cmpType) => { | ||
/** @type {?} */ | ||
const originalFactory = cmpType.ngComponentDef.factory; | ||
cmpType.ngComponentDef.factory = (/** | ||
* @return {?} | ||
*/ | ||
() => { | ||
/** @type {?} */ | ||
const cmp = originalFactory(cmpType.ngComponentDef.type); | ||
/** @type {?} */ | ||
const storeon = ɵɵdirectiveInject(StoreonService); | ||
config.keys.forEach((/** | ||
* @param {?} key | ||
* @return {?} | ||
*/ | ||
key => cmp[key] = storeon.useStoreon(key))); | ||
if (config.dispatcher) { | ||
cmp[config.dispatcher] = storeon.dispatch.bind(storeon); | ||
} | ||
return cmp; | ||
}); | ||
}); | ||
} | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
export { StoreonService, StoreonModule, STOREON }; | ||
//# sourceMappingURL=storeon-angular.js.map | ||
export { STOREON, StoreonService, UseStoreon }; | ||
//# sourceMappingURL=storeon-angular.js.map |
import { __assign } from 'tslib'; | ||
import { InjectionToken, Injectable, Inject, ɵɵdefineInjectable, ɵɵinject, ɵɵdirectiveInject } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { pluck, map, distinctUntilChanged } from 'rxjs/operators'; | ||
import 'storeon'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { distinctUntilChanged, map, pluck } from 'rxjs/operators'; | ||
import { InjectionToken, Injectable, Inject, NgModule, defineInjectable, inject } from '@angular/core'; | ||
@@ -19,3 +19,3 @@ /** | ||
/** | ||
* @template State | ||
* @template State, Events | ||
*/ | ||
@@ -64,2 +64,3 @@ var StoreonService = /** @class */ (function () { | ||
/** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -70,2 +71,3 @@ * @param {?=} data | ||
StoreonService.prototype.dispatch = /** | ||
* @template E, K | ||
* @param {?} event | ||
@@ -98,3 +100,3 @@ * @param {?=} data | ||
]; }; | ||
/** @nocollapse */ StoreonService.ngInjectableDef = defineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(inject(STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
/** @nocollapse */ StoreonService.ngInjectableDef = ɵɵdefineInjectable({ factory: function StoreonService_Factory() { return new StoreonService(ɵɵinject(STOREON)); }, token: StoreonService, providedIn: "root" }); | ||
return StoreonService; | ||
@@ -107,28 +109,42 @@ }()); | ||
*/ | ||
var StoreonModule = /** @class */ (function () { | ||
function StoreonModule() { | ||
} | ||
StoreonModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [], | ||
imports: [], | ||
providers: [], | ||
exports: [] | ||
},] } | ||
]; | ||
return StoreonModule; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
* | ||
* | ||
* Experimental feature, works only with Ivy renderer | ||
* Patches the component with keys from storeon store | ||
* | ||
* @template State, Events | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function UseStoreon(config) { | ||
return (/** | ||
* @param {?} cmpType | ||
* @return {?} | ||
*/ | ||
function (cmpType) { | ||
/** @type {?} */ | ||
var originalFactory = cmpType.ngComponentDef.factory; | ||
cmpType.ngComponentDef.factory = (/** | ||
* @return {?} | ||
*/ | ||
function () { | ||
/** @type {?} */ | ||
var cmp = originalFactory(cmpType.ngComponentDef.type); | ||
/** @type {?} */ | ||
var storeon = ɵɵdirectiveInject(StoreonService); | ||
config.keys.forEach((/** | ||
* @param {?} key | ||
* @return {?} | ||
*/ | ||
function (key) { return cmp[key] = storeon.useStoreon(key); })); | ||
if (config.dispatcher) { | ||
cmp[config.dispatcher] = storeon.dispatch.bind(storeon); | ||
} | ||
return cmp; | ||
}); | ||
}); | ||
} | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
export { StoreonService, StoreonModule, STOREON }; | ||
//# sourceMappingURL=storeon-angular.js.map | ||
export { STOREON, StoreonService, UseStoreon }; | ||
//# sourceMappingURL=storeon-angular.js.map |
import { OnDestroy } from '@angular/core'; | ||
import * as createStore from 'storeon'; | ||
import { Observable } from 'rxjs'; | ||
export declare class StoreonService<State> implements OnDestroy { | ||
import createStore from 'storeon'; | ||
export declare class StoreonService<State, Events> implements OnDestroy { | ||
private store; | ||
@@ -11,4 +11,4 @@ private state$; | ||
useStoreon<K extends keyof State>(path: K): Observable<State[K]>; | ||
dispatch(event: string, data?: unknown): void; | ||
dispatch<E extends Events, K extends keyof E>(event: K, data?: E[K]): void; | ||
ngOnDestroy(): void; | ||
} |
{ | ||
"name": "@storeon/angular", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Storeon for Angular 🅰⚡", | ||
"peerDependencies": { | ||
"@angular/common": "^8.0.1", | ||
"@angular/core": "^8.0.1", | ||
"storeon": "^0.8.5" | ||
"@angular/common": "^8.1.0", | ||
"@angular/core": "^8.1.0", | ||
"storeon": "^0.9.1" | ||
}, | ||
@@ -10,0 +10,0 @@ "license": "MIT", |
export * from './lib/storeon.service'; | ||
export * from './lib/storeon.module'; | ||
export * from './lib/storeon.token'; | ||
export * from './lib/storeon.decorator'; |
@@ -21,32 +21,47 @@ # @storeon/angular | ||
## Compatibility | ||
*@storeon/angular* **0.2.0**+ supports Angular **8** | ||
*@storeon/angular* **0.1.0** supports Angular **7** | ||
## How to use | ||
```typescript | ||
import * as createStore from 'storeon' | ||
import * as devTools from 'storeon/devtools'; | ||
import createStore, { Module, StoreonEvents } from 'storeon'; | ||
import devtools from 'storeon/devtools'; | ||
import { environment } from 'src/environments/environment'; | ||
// State structure | ||
export interface State { | ||
count: number | ||
count: number; | ||
} | ||
// Events declaration: map of event names to type of event data | ||
export interface Events extends StoreonEvents<State> { | ||
// `inc` event which does not go with any data | ||
'inc': undefined; | ||
} | ||
// Initial state, reducers and business logic are packed in independent modules | ||
let increment = (store: createStore.Store<State>) => { | ||
const counterModule: Module<State, Events> = store => { | ||
// Initial state | ||
store.on('@init', () => ({ count: 0 })) | ||
// Reducers returns only changed part of the state | ||
store.on('inc', ({ count }) => ({ count: count + 1 })) | ||
} | ||
store.on('@init', () => ({ | ||
count: 0 | ||
})); | ||
export const store = createStore([increment, !environment.production && devTools]) | ||
// Events | ||
store.on('inc', ({ count }) => ({ count: count + 1 })); | ||
}; | ||
export const defaultStore = createStore<State, Events>([counterModule, !environment.production && devtools]); | ||
// your NgModule | ||
import { StoreonModule, STOREON } from '@storeon/angular'; | ||
import { STOREON } from '@storeon/angular'; | ||
@NgModule({ | ||
imports: [StoreonModule], // StoreonModule | ||
... | ||
providers: [{ | ||
provide: STOREON, | ||
useValue: store // your store | ||
useValue: defaultStore // your store | ||
}], | ||
@@ -61,4 +76,5 @@ ... | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { StoreonService } from '@storeon/angular'; | ||
import { State } from './app.module'; | ||
import { State, Events } from '../app.module'; | ||
@@ -72,3 +88,3 @@ @Component({ | ||
changes: Observable<number>; | ||
constructor(private storeon: StoreonService<State>) { } | ||
constructor(private storeon: StoreonService<State, Events>) { } | ||
title = 'storeon-angular'; | ||
@@ -86,1 +102,34 @@ | ||
``` | ||
```typescript | ||
// example using Ivy hooks | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { UseStoreon } from '@storeon/angular'; | ||
import { Events, State } from '../app.module'; | ||
import { Dispatch } from 'storeon'; | ||
@Component({ | ||
selector: 'app-hook-counter', | ||
templateUrl: './hook-counter.component.html', | ||
styleUrls: ['./hook-counter.component.scss'] | ||
}) | ||
@UseStoreon<State, Events>({keys: [ 'count' ], dispatcher: 'dispatch'}) | ||
export class HookCounterComponent implements OnInit { | ||
count: Observable<number>; | ||
dispatch: Dispatch<Events>; | ||
constructor() { } | ||
ngOnInit() { | ||
} | ||
increment() { | ||
this.dispatch('inc'); | ||
} | ||
} | ||
``` |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"StoreonService":{"__symbolic":"class","arity":1,"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":6,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":15,"character":15},"arguments":[{"__symbolic":"reference","name":"STOREON"}]}]],"parameters":[{"__symbolic":"reference","name":"Store","module":"storeon","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":15,"character":64,"context":{"typeName":"State"},"module":"./lib/storeon.service"}]}]}],"useStoreon":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"dispatch":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"StoreonModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"declarations":[],"imports":[],"providers":[],"exports":[]}]}],"members":{}},"STOREON":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":2,"character":27},"arguments":["Token for store object"]}},"origins":{"StoreonService":"./lib/storeon.service","StoreonModule":"./lib/storeon.module","STOREON":"./lib/storeon.token"},"importAs":"@storeon/angular"} | ||
{"__symbolic":"module","version":4,"metadata":{"StoreonService":{"__symbolic":"class","arity":2,"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":6,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":15,"character":15},"arguments":[{"__symbolic":"reference","name":"STOREON"}]}]],"parameters":[{"__symbolic":"select","member":"Store","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":15,"character":64,"context":{"typeName":"State"},"module":"./lib/storeon.service"}]}]}],"useStoreon":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"dispatch":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"STOREON":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":2,"character":27},"arguments":["Token for store object"]},"UseStoreon":{"__symbolic":"function","parameters":["config"],"value":{"__symbolic":"error","message":"Lambda not supported","line":14,"character":9,"module":"./lib/storeon.decorator"}}},"origins":{"StoreonService":"./lib/storeon.service","STOREON":"./lib/storeon.token","UseStoreon":"./lib/storeon.decorator"},"importAs":"@storeon/angular"} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
90751
824
132