Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storeon/angular

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storeon/angular - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

esm2015/lib/storeon.token.js

126

bundles/storeon-angular.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('@angular/core')) :
typeof define === 'function' && define.amd ? define('@storeon/angular', ['exports', 'rxjs', '@angular/core'], factory) :
(factory((global.storeon = global.storeon || {}, global.storeon.angular = {}),global.rxjs,global.ng.core));
}(this, (function (exports,rxjs,i0) { 'use strict';
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';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
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];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -11,41 +38,75 @@ * @fileoverview added by tsickle

*/
/** @type {?} */
var STOREON = new i0.InjectionToken('Token for store object');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template State
*/
var NgStoreonService = /** @class */ (function () {
function NgStoreonService(store) {
var _this = this;
this.store = store;
this.state$ = new rxjs.BehaviorSubject(this.store.get());
this.unbind = this.store.on('@changed', ( /**
* @param {?} state
* @return {?}
*/function (state) {
_this.state$.next(__assign({}, ( /** @type {?} */(state))));
return null;
}));
}
/**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
NgStoreonService.prototype.useStoreon = /**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
function () {
var keys = [];
for (var _i = 0; _i < arguments.length; _i++) {
keys[_i] = arguments[_i];
function (pathOrMapFn) {
/** @type {?} */
var mapped$;
if (typeof pathOrMapFn === 'string') {
mapped$ = this.state$.pipe(operators.pluck(pathOrMapFn));
}
/** @type {?} */
var obs = new rxjs.Subject();
this.store.on('@changed', ( /**
* @param {?} _
* @param {?} changed
* @return {?}
*/function (_, changed) {
/** @type {?} */
var changesInKeys = keys.some(( /**
* @param {?} key
else if (typeof pathOrMapFn === 'function') {
mapped$ = this.state$.pipe(operators.map(( /**
* @param {?} source
* @return {?}
*/function (key) { return key in changed; }));
if (changesInKeys) {
obs.next(changed);
}
return null;
}));
return {
dispatch: this.store.dispatch,
changes: obs
};
*/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());
};
/**
* @param {?} event
* @param {?=} data
* @return {?}
*/
NgStoreonService.prototype.dispatch = /**
* @param {?} event
* @param {?=} data
* @return {?}
*/
function (event, data) {
this.store.dispatch(event, data);
};
/**
* @return {?}
*/
NgStoreonService.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this.unbind) {
this.unbind();
}
};
NgStoreonService.decorators = [

@@ -59,6 +120,6 @@ { type: i0.Injectable, args: [{

return [
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: ['STOREON',] }] }
{ type: undefined, decorators: [{ type: i0.Inject, args: [STOREON,] }] }
];
};
/** @nocollapse */ NgStoreonService.ngInjectableDef = i0.defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(i0.inject("STOREON", 8)); }, token: NgStoreonService, providedIn: "root" });
/** @nocollapse */ NgStoreonService.ngInjectableDef = i0.defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(i0.inject(STOREON)); }, token: NgStoreonService, providedIn: "root" });
return NgStoreonService;

@@ -97,2 +158,3 @@ }());

exports.NgStoreonModule = NgStoreonModule;
exports.STOREON = STOREON;

@@ -99,0 +161,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("@angular/core")):"function"==typeof define&&define.amd?define("@storeon/angular",["exports","rxjs","@angular/core"],t):t((e.storeon=e.storeon||{},e.storeon.angular={}),e.rxjs,e.ng.core)}(this,function(e,t,r){"use strict";var o=(n.prototype.useStoreon=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var o=new t.Subject;return this.store.on("@changed",function(e,t){return r.some(function(e){return e in t})&&o.next(t),null}),{dispatch:this.store.dispatch,changes:o}},n.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],n.ctorParameters=function(){return[{type:undefined,decorators:[{type:r.Optional},{type:r.Inject,args:["STOREON"]}]}]},n.ngInjectableDef=r.defineInjectable({factory:function(){return new n(r.inject("STOREON",8))},token:n,providedIn:"root"}),n);function n(e){this.store=e}var s=(i.decorators=[{type:r.NgModule,args:[{declarations:[],imports:[],providers:[],exports:[]}]}],i);function i(){}e.NgStoreonService=o,e.NgStoreonModule=s,Object.defineProperty(e,"__esModule",{value:!0})});
!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.NgStoreonService=s,e.NgStoreonModule=c,e.STOREON=i,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=storeon-angular.umd.min.js.map

@@ -5,6 +5,12 @@ /**

*/
import { Injectable, Inject, Optional } from '@angular/core';
import { Injectable, Inject } from '@angular/core';
import * as createStore from 'storeon';
import { Subject } from 'rxjs';
import { BehaviorSubject } from 'rxjs';
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
*/
export class NgStoreonService {

@@ -16,32 +22,51 @@ /**

this.store = store;
this.state$ = new BehaviorSubject(this.store.get());
this.unbind = this.store.on('@changed', (/**
* @param {?} state
* @return {?}
*/
(state) => {
this.state$.next(Object.assign({}, (/** @type {?} */ (state))));
return null;
}));
}
/**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
useStoreon(...keys) {
useStoreon(pathOrMapFn) {
/** @type {?} */
const obs = new Subject();
this.store.on('@changed', (/**
* @param {?} _
* @param {?} changed
* @return {?}
*/
(_, changed) => {
/** @type {?} */
const changesInKeys = keys.some((/**
* @param {?} key
let mapped$;
if (typeof pathOrMapFn === 'string') {
mapped$ = this.state$.pipe(pluck(pathOrMapFn));
}
else if (typeof pathOrMapFn === 'function') {
mapped$ = this.state$.pipe(map((/**
* @param {?} source
* @return {?}
*/
key => key in changed));
if (changesInKeys) {
obs.next(changed);
}
return null;
}));
return {
dispatch: this.store.dispatch,
changes: obs
};
source => pathOrMapFn(source))));
}
else {
throw new TypeError(`Unexpected type '${typeof pathOrMapFn}' in select operator,` +
` expected 'string' or 'function'`);
}
return mapped$.pipe(distinctUntilChanged());
}
/**
* @param {?} event
* @param {?=} data
* @return {?}
*/
dispatch(event, data) {
this.store.dispatch(event, data);
}
/**
* @return {?}
*/
ngOnDestroy() {
if (this.unbind) {
this.unbind();
}
}
}

@@ -55,9 +80,22 @@ NgStoreonService.decorators = [

NgStoreonService.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: ['STOREON',] }] }
{ type: undefined, decorators: [{ type: Inject, args: [STOREON,] }] }
];
/** @nocollapse */ NgStoreonService.ngInjectableDef = i0.defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(i0.inject("STOREON", 8)); }, token: NgStoreonService, providedIn: "root" });
/** @nocollapse */ NgStoreonService.ngInjectableDef = i0.defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(i0.inject(i1.STOREON)); }, token: NgStoreonService, providedIn: "root" });
if (false) {
/** @type {?} */
/**
* @type {?}
* @private
*/
NgStoreonService.prototype.state$;
/**
* @type {?}
* @private
*/
NgStoreonService.prototype.unbind;
/**
* @type {?}
* @private
*/
NgStoreonService.prototype.store;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctc3RvcmVvbi5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbImxpYi9uZy1zdG9yZW9uLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUM3RCxPQUFPLEtBQUssV0FBVyxNQUFNLFNBQVMsQ0FBQztBQUN2QyxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sTUFBTSxDQUFDOztBQUkvQixNQUFNLE9BQU8sZ0JBQWdCOzs7O0lBQzNCLFlBQWtELEtBQXdCO1FBQXhCLFVBQUssR0FBTCxLQUFLLENBQW1CO0lBQUksQ0FBQzs7Ozs7SUFDL0UsVUFBVSxDQUFDLEdBQUcsSUFBYzs7Y0FDcEIsR0FBRyxHQUFHLElBQUksT0FBTyxFQUFFO1FBQ3pCLElBQUksQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDLFVBQVU7Ozs7O1FBQUUsQ0FBQyxDQUFDLEVBQUUsT0FBTyxFQUFFLEVBQUU7O2tCQUNqQyxhQUFhLEdBQUcsSUFBSSxDQUFDLElBQUk7Ozs7WUFBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsSUFBSSxPQUFPLEVBQU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iAgICB0aGlzLnN0b3JlLmRpc3BhdGNoKGV2ZW50LCBkYXRhKTtcbiAgfVxuXG4gIG5nT25EZXN0cm95KCk6IHZvaWQge1xuICAgIGlmICh0aGlzLnVuYmluZCkge1xuICAgICAgdGhpcy51bmJpbmQoKTtcbiAgICB9XG4gIH1cblxufVxuIl19

@@ -6,6 +6,7 @@ /**

/*
* Public API Surface of ng-storeon
* Public API Surface of @storeon/angular
*/
export { NgStoreonService } from './lib/ng-storeon.service';
export { NgStoreonModule } from './lib/ng-storeon.module';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxpQ0FBYywwQkFBMEIsQ0FBQztBQUN6QyxnQ0FBYyx5QkFBeUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbmctc3RvcmVvblxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL25nLXN0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZy1zdG9yZW9uLm1vZHVsZSc7XG4iXX0=
export { STOREON } from './lib/storeon.token';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxpQ0FBYywwQkFBMEIsQ0FBQztBQUN6QyxnQ0FBYyx5QkFBeUIsQ0FBQztBQUN4Qyx3QkFBYyxxQkFBcUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgQHN0b3Jlb24vYW5ndWxhclxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL25nLXN0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZy1zdG9yZW9uLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLnRva2VuJztcbiJdfQ==

@@ -8,3 +8,3 @@ /**

*/
export { NgStoreonService, NgStoreonModule } from './public_api';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsa0RBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19
export { NgStoreonService, NgStoreonModule, STOREON } from './public_api';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsMkRBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19

@@ -0,0 +0,0 @@ /**

@@ -5,47 +5,78 @@ /**

*/
import { Injectable, Inject, Optional } from '@angular/core';
import * as tslib_1 from "tslib";
import { Injectable, Inject } from '@angular/core';
import * as createStore from 'storeon';
import { Subject } from 'rxjs';
import { BehaviorSubject } from 'rxjs';
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
*/
var NgStoreonService = /** @class */ (function () {
function NgStoreonService(store) {
var _this = this;
this.store = store;
this.state$ = new BehaviorSubject(this.store.get());
this.unbind = this.store.on('@changed', (/**
* @param {?} state
* @return {?}
*/
function (state) {
_this.state$.next(tslib_1.__assign({}, (/** @type {?} */ (state))));
return null;
}));
}
/**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
NgStoreonService.prototype.useStoreon = /**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
function () {
var keys = [];
for (var _i = 0; _i < arguments.length; _i++) {
keys[_i] = arguments[_i];
function (pathOrMapFn) {
/** @type {?} */
var mapped$;
if (typeof pathOrMapFn === 'string') {
mapped$ = this.state$.pipe(pluck(pathOrMapFn));
}
/** @type {?} */
var obs = new Subject();
this.store.on('@changed', (/**
* @param {?} _
* @param {?} changed
* @return {?}
*/
function (_, changed) {
/** @type {?} */
var changesInKeys = keys.some((/**
* @param {?} key
else if (typeof pathOrMapFn === 'function') {
mapped$ = this.state$.pipe(map((/**
* @param {?} source
* @return {?}
*/
function (key) { return key in changed; }));
if (changesInKeys) {
obs.next(changed);
}
return null;
}));
return {
dispatch: this.store.dispatch,
changes: obs
};
function (source) { return pathOrMapFn(source); })));
}
else {
throw new TypeError("Unexpected type '" + typeof pathOrMapFn + "' in select operator," +
" expected 'string' or 'function'");
}
return mapped$.pipe(distinctUntilChanged());
};
/**
* @param {?} event
* @param {?=} data
* @return {?}
*/
NgStoreonService.prototype.dispatch = /**
* @param {?} event
* @param {?=} data
* @return {?}
*/
function (event, data) {
this.store.dispatch(event, data);
};
/**
* @return {?}
*/
NgStoreonService.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this.unbind) {
this.unbind();
}
};
NgStoreonService.decorators = [

@@ -58,5 +89,5 @@ { type: Injectable, args: [{

NgStoreonService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: ['STOREON',] }] }
{ type: undefined, decorators: [{ type: Inject, args: [STOREON,] }] }
]; };
/** @nocollapse */ NgStoreonService.ngInjectableDef = i0.defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(i0.inject("STOREON", 8)); }, token: NgStoreonService, providedIn: "root" });
/** @nocollapse */ NgStoreonService.ngInjectableDef = i0.defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(i0.inject(i1.STOREON)); }, token: NgStoreonService, providedIn: "root" });
return NgStoreonService;

@@ -66,5 +97,18 @@ }());

if (false) {
/** @type {?} */
/**
* @type {?}
* @private
*/
NgStoreonService.prototype.state$;
/**
* @type {?}
* @private
*/
NgStoreonService.prototype.unbind;
/**
* @type {?}
* @private
*/
NgStoreonService.prototype.store;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctc3RvcmVvbi5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbImxpYi9uZy1zdG9yZW9uLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUM3RCxPQUFPLEtBQUssV0FBVyxNQUFNLFNBQVMsQ0FBQztBQUN2QyxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQ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dGhpcy5zdGF0ZSQucGlwZShwbHVjayhwYXRoT3JNYXBGbikpO1xuICAgIH0gZWxzZSBpZiAodHlwZW9mIHBhdGhPck1hcEZuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICBtYXBwZWQkID0gdGhpcy5zdGF0ZSQucGlwZShcbiAgICAgICAgbWFwKHNvdXJjZSA9PiBwYXRoT3JNYXBGbihzb3VyY2UpKVxuICAgICAgKTtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihcbiAgICAgICAgYFVuZXhwZWN0ZWQgdHlwZSAnJHt0eXBlb2YgcGF0aE9yTWFwRm59JyBpbiBzZWxlY3Qgb3BlcmF0b3IsYCArXG4gICAgICAgIGAgZXhwZWN0ZWQgJ3N0cmluZycgb3IgJ2Z1bmN0aW9uJ2BcbiAgICAgICk7XG4gICAgfVxuXG4gICAgcmV0dXJuIG1hcHBlZCQucGlwZShkaXN0aW5jdFVudGlsQ2hhbmdlZCgpKTtcbiAgfVxuXG4gIGRpc3BhdGNoKGV2ZW50OiBzdHJpbmcsIGRhdGE/OiB1bmtub3duKSB7XG4gICAgdGhpcy5zdG9yZS5kaXNwYXRjaChldmVudCwgZGF0YSk7XG4gIH1cblxuICBuZ09uRGVzdHJveSgpOiB2b2lkIHtcbiAgICBpZiAodGhpcy51bmJpbmQpIHtcbiAgICAgIHRoaXMudW5iaW5kKCk7XG4gICAgfVxuICB9XG5cbn1cbiJdfQ==

@@ -6,6 +6,7 @@ /**

/*
* Public API Surface of ng-storeon
* Public API Surface of @storeon/angular
*/
export { NgStoreonService } from './lib/ng-storeon.service';
export { NgStoreonModule } from './lib/ng-storeon.module';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxpQ0FBYywwQkFBMEIsQ0FBQztBQUN6QyxnQ0FBYyx5QkFBeUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbmctc3RvcmVvblxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL25nLXN0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZy1zdG9yZW9uLm1vZHVsZSc7XG4iXX0=
export { STOREON } from './lib/storeon.token';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzdG9yZW9uL2FuZ3VsYXIvIiwic291cmNlcyI6WyJwdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxpQ0FBYywwQkFBMEIsQ0FBQztBQUN6QyxnQ0FBYyx5QkFBeUIsQ0FBQztBQUN4Qyx3QkFBYyxxQkFBcUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgQHN0b3Jlb24vYW5ndWxhclxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL25nLXN0b3Jlb24uc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZy1zdG9yZW9uLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zdG9yZW9uLnRva2VuJztcbiJdfQ==

@@ -8,3 +8,3 @@ /**

*/
export { NgStoreonService, NgStoreonModule } from './public_api';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsa0RBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19
export { NgStoreonService, NgStoreonModule, STOREON } from './public_api';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVvbi1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN0b3Jlb24vYW5ndWxhci8iLCJzb3VyY2VzIjpbInN0b3Jlb24tYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsMkRBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19
import 'storeon';
import { Subject } from 'rxjs';
import { Injectable, Inject, Optional, NgModule, defineInjectable, inject } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { distinctUntilChanged, map, pluck } from 'rxjs/operators';
import { InjectionToken, Injectable, Inject, NgModule, defineInjectable, inject } from '@angular/core';

@@ -9,2 +10,12 @@ /**

*/
/** @type {?} */
const STOREON = new InjectionToken('Token for store object');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template State
*/
class NgStoreonService {

@@ -16,32 +27,51 @@ /**

this.store = store;
this.state$ = new BehaviorSubject(this.store.get());
this.unbind = this.store.on('@changed', (/**
* @param {?} state
* @return {?}
*/
(state) => {
this.state$.next(Object.assign({}, (/** @type {?} */ (state))));
return null;
}));
}
/**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
useStoreon(...keys) {
useStoreon(pathOrMapFn) {
/** @type {?} */
const obs = new Subject();
this.store.on('@changed', (/**
* @param {?} _
* @param {?} changed
* @return {?}
*/
(_, changed) => {
/** @type {?} */
const changesInKeys = keys.some((/**
* @param {?} key
let mapped$;
if (typeof pathOrMapFn === 'string') {
mapped$ = this.state$.pipe(pluck(pathOrMapFn));
}
else if (typeof pathOrMapFn === 'function') {
mapped$ = this.state$.pipe(map((/**
* @param {?} source
* @return {?}
*/
key => key in changed));
if (changesInKeys) {
obs.next(changed);
}
return null;
}));
return {
dispatch: this.store.dispatch,
changes: obs
};
source => pathOrMapFn(source))));
}
else {
throw new TypeError(`Unexpected type '${typeof pathOrMapFn}' in select operator,` +
` expected 'string' or 'function'`);
}
return mapped$.pipe(distinctUntilChanged());
}
/**
* @param {?} event
* @param {?=} data
* @return {?}
*/
dispatch(event, data) {
this.store.dispatch(event, data);
}
/**
* @return {?}
*/
ngOnDestroy() {
if (this.unbind) {
this.unbind();
}
}
}

@@ -55,5 +85,5 @@ NgStoreonService.decorators = [

NgStoreonService.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: ['STOREON',] }] }
{ type: undefined, decorators: [{ type: Inject, args: [STOREON,] }] }
];
/** @nocollapse */ NgStoreonService.ngInjectableDef = defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(inject("STOREON", 8)); }, token: NgStoreonService, providedIn: "root" });
/** @nocollapse */ NgStoreonService.ngInjectableDef = defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(inject(STOREON)); }, token: NgStoreonService, providedIn: "root" });

@@ -85,4 +115,4 @@ /**

export { NgStoreonService, NgStoreonModule };
export { NgStoreonService, NgStoreonModule, STOREON };
//# sourceMappingURL=storeon-angular.js.map

@@ -0,4 +1,6 @@

import { __assign } from 'tslib';
import 'storeon';
import { Subject } from 'rxjs';
import { Injectable, Inject, Optional, NgModule, defineInjectable, inject } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { distinctUntilChanged, map, pluck } from 'rxjs/operators';
import { InjectionToken, Injectable, Inject, NgModule, defineInjectable, inject } from '@angular/core';

@@ -9,43 +11,77 @@ /**

*/
/** @type {?} */
var STOREON = new InjectionToken('Token for store object');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template State
*/
var NgStoreonService = /** @class */ (function () {
function NgStoreonService(store) {
var _this = this;
this.store = store;
this.state$ = new BehaviorSubject(this.store.get());
this.unbind = this.store.on('@changed', (/**
* @param {?} state
* @return {?}
*/
function (state) {
_this.state$.next(__assign({}, (/** @type {?} */ (state))));
return null;
}));
}
/**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
NgStoreonService.prototype.useStoreon = /**
* @param {...?} keys
* @param {?} pathOrMapFn
* @return {?}
*/
function () {
var keys = [];
for (var _i = 0; _i < arguments.length; _i++) {
keys[_i] = arguments[_i];
function (pathOrMapFn) {
/** @type {?} */
var mapped$;
if (typeof pathOrMapFn === 'string') {
mapped$ = this.state$.pipe(pluck(pathOrMapFn));
}
/** @type {?} */
var obs = new Subject();
this.store.on('@changed', (/**
* @param {?} _
* @param {?} changed
* @return {?}
*/
function (_, changed) {
/** @type {?} */
var changesInKeys = keys.some((/**
* @param {?} key
else if (typeof pathOrMapFn === 'function') {
mapped$ = this.state$.pipe(map((/**
* @param {?} source
* @return {?}
*/
function (key) { return key in changed; }));
if (changesInKeys) {
obs.next(changed);
}
return null;
}));
return {
dispatch: this.store.dispatch,
changes: obs
};
function (source) { return pathOrMapFn(source); })));
}
else {
throw new TypeError("Unexpected type '" + typeof pathOrMapFn + "' in select operator," +
" expected 'string' or 'function'");
}
return mapped$.pipe(distinctUntilChanged());
};
/**
* @param {?} event
* @param {?=} data
* @return {?}
*/
NgStoreonService.prototype.dispatch = /**
* @param {?} event
* @param {?=} data
* @return {?}
*/
function (event, data) {
this.store.dispatch(event, data);
};
/**
* @return {?}
*/
NgStoreonService.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this.unbind) {
this.unbind();
}
};
NgStoreonService.decorators = [

@@ -58,5 +94,5 @@ { type: Injectable, args: [{

NgStoreonService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: ['STOREON',] }] }
{ type: undefined, decorators: [{ type: Inject, args: [STOREON,] }] }
]; };
/** @nocollapse */ NgStoreonService.ngInjectableDef = defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(inject("STOREON", 8)); }, token: NgStoreonService, providedIn: "root" });
/** @nocollapse */ NgStoreonService.ngInjectableDef = defineInjectable({ factory: function NgStoreonService_Factory() { return new NgStoreonService(inject(STOREON)); }, token: NgStoreonService, providedIn: "root" });
return NgStoreonService;

@@ -93,4 +129,4 @@ }());

export { NgStoreonService, NgStoreonModule };
export { NgStoreonService, NgStoreonModule, STOREON };
//# sourceMappingURL=storeon-angular.js.map
export declare class NgStoreonModule {
}

@@ -0,10 +1,13 @@

import { OnDestroy } from '@angular/core';
import * as createStore from 'storeon';
import { Subject } from 'rxjs';
export declare class NgStoreonService {
store: createStore.Store;
constructor(store: createStore.Store);
useStoreon(...keys: string[]): {
dispatch: createStore.Dispatch;
changes: Subject<{}>;
};
import { Observable } from 'rxjs';
export declare class NgStoreonService<State> implements OnDestroy {
private store;
private state$;
private readonly unbind;
constructor(store: createStore.Store<State>);
useStoreon<K>(mapFn: (state: State) => K): Observable<K>;
useStoreon<K extends keyof State>(path: K): Observable<State[K]>;
dispatch(event: string, data?: unknown): void;
ngOnDestroy(): void;
}
{
"name": "@storeon/angular",
"version": "0.0.1",
"version": "0.1.0",
"description": "Storeon for Angular 🅰⚡",
"peerDependencies": {

@@ -5,0 +6,0 @@ "@angular/common": "^7.0.0",

export * from './lib/ng-storeon.service';
export * from './lib/ng-storeon.module';
export * from './lib/storeon.token';

@@ -1,2 +0,2 @@

# ng-storeon
# @storeon/angular

@@ -10,3 +10,3 @@ <img src="https://storeon.github.io/storeon/logo.svg" align="right"

It is just 526 bytes (minified and gzipped) Angular module. It uses [Size Limit] to control size.
It is just 533 bytes (minified and gzipped) Angular module. It uses [Size Limit] to control size.

@@ -25,6 +25,11 @@ Read more about Storeon **[article]**.

```typescript
import createStore from 'storeon'
import * as createStore from 'storeon'
import * as devTools from 'storeon/devtools';
export interface State {
count: number
}
// Initial state, reducers and business logic are packed in independent modules
let increment = store => {
let increment = (store: createStore.Store<State>) => {
// Initial state

@@ -36,7 +41,7 @@ store.on('@init', () => ({ count: 0 }))

export const store = createStore([increment])
export const store = createStore([increment, !environment.production && devTools])
// your NgModule
import { NgStoreonModule } from 'ng-storeon';
import { NgStoreonModule, STOREON } from '@storeon/angular';

@@ -47,3 +52,3 @@ @NgModule({

providers: [{
provide: 'STOREON',
provide: STOREON,
useValue: store // your store

@@ -59,3 +64,4 @@ }],

import { Component, OnInit } from '@angular/core';
import { NgStoreonService } from 'ng-storeon';
import { NgStoreonService } from '@storeon/angular';
import { State } from './app.module';

@@ -68,15 +74,12 @@ @Component({

export class AppComponent implements OnInit {
changes: Subject<any>;
dispatch: Function;
constructor(private ngstoreon: NgStoreonService) { }
title = 'sroreon-angular';
changes: Observable<number>;
constructor(private ngstoreon: NgStoreonService<State>) { }
title = 'storeon-angular';
ngOnInit() {
const { dispatch, changes } = this.ngstoreon.useStoreon('count');
this.dispatch = dispatch;
this.changes = changes;
this.changes = this.ngstoreon.useStoreon('count');
}
updateState() {
this.dispatch('inc');
this.ngstoreon.dispatch('inc');
}

@@ -83,0 +86,0 @@ }

@@ -0,0 +0,0 @@ /**

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"NgStoreonService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":3,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":7,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":7,"character":27},"arguments":["STOREON"]}]],"parameters":[{"__symbolic":"reference","module":"storeon","name":"Store","line":7,"character":59}]}],"useStoreon":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"NgStoreonModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"declarations":[],"imports":[],"providers":[],"exports":[]}]}],"members":{}}},"origins":{"NgStoreonService":"./lib/ng-storeon.service","NgStoreonModule":"./lib/ng-storeon.module"},"importAs":"@storeon/angular"}
{"__symbolic":"module","version":4,"metadata":{"NgStoreonService":{"__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/ng-storeon.service"}]}]}],"useStoreon":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"dispatch":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"NgStoreonModule":{"__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":{"NgStoreonService":"./lib/ng-storeon.service","NgStoreonModule":"./lib/ng-storeon.module","STOREON":"./lib/storeon.token"},"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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc