@ngneat/elf
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0
import { BehaviorSubject, Observable } from 'rxjs'; | ||
import { Query } from '..'; | ||
export declare class Store<SDef extends StoreDef = any, State = SDef['state']> extends BehaviorSubject<State> { | ||
@@ -7,5 +8,5 @@ private storeDef; | ||
constructor(storeDef: SDef); | ||
get name(): string; | ||
get name(): StoreDef['name']; | ||
getConfig<Config extends Record<any, any>>(): Config; | ||
query<R>(selector: (state: State) => R): R; | ||
query<R>(selector: Query<State, R>): R; | ||
update(...reducers: Array<Reducer<State>>): void; | ||
@@ -21,7 +22,7 @@ reset(): void; | ||
} | ||
export declare type StoreValue<T extends Store> = ReturnType<T['getValue']>; | ||
export declare type Reducer<State> = (state: State, context: ReducerContext) => State; | ||
export declare type ReducerContext = { | ||
config: Record<PropertyKey, any>; | ||
}; | ||
export declare type StoreValue<T extends Store> = ReturnType<T['getValue']>; | ||
export declare type Reducer<State> = (state: State, context: ReducerContext) => State; | ||
export interface StoreDef<State = any> { | ||
@@ -28,0 +29,0 @@ name: string; |
{ | ||
"name": "@ngneat/elf", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0", | ||
"description": "A reactive state management for JS applications", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -11,3 +11,3 @@ <p align="center"> | ||
Elf encourages simplicity. It eases the hassle of creating boilerplate code and comes with robust tools, suitable for both experienced and inexperienced developers. | ||
Elf encourages simplicity. It saves you the hassle of creating boilerplate code and offers powerful tools with a moderate learning curve, suitable for experienced and inexperienced developers alike. | ||
@@ -14,0 +14,0 @@ ✅ Modular by design |
@@ -193,5 +193,5 @@ import { Subject, BehaviorSubject, Observable, pipe, asapScheduler } from 'rxjs'; | ||
return { ...state, | ||
return Object.assign({}, state, { | ||
[key]: newVal | ||
}; | ||
}); | ||
}; | ||
@@ -208,7 +208,5 @@ }, | ||
return { ...state, | ||
[key]: isObject(newVal) ? { ...state[key], | ||
...newVal | ||
} : newVal | ||
}; | ||
return Object.assign({}, state, { | ||
[key]: isObject(newVal) ? Object.assign({}, state[key], newVal) : newVal | ||
}); | ||
}; | ||
@@ -219,5 +217,5 @@ }, | ||
return function (state) { | ||
return { ...state, | ||
return Object.assign({}, state, { | ||
[key]: initialValue | ||
}; | ||
}); | ||
}; | ||
@@ -240,9 +238,8 @@ }, | ||
const base = propsFactory(key, options); | ||
return { ...base, | ||
return Object.assign({}, base, { | ||
[`add${normalizedKey}`](items) { | ||
return function (state) { | ||
return { ...state, | ||
return Object.assign({}, state, { | ||
[key]: arrayAdd(state[key], items) | ||
}; | ||
}); | ||
}; | ||
@@ -253,5 +250,5 @@ }, | ||
return function (state) { | ||
return { ...state, | ||
return Object.assign({}, state, { | ||
[key]: arrayRemove(state[key], items) | ||
}; | ||
}); | ||
}; | ||
@@ -262,5 +259,5 @@ }, | ||
return function (state) { | ||
return { ...state, | ||
return Object.assign({}, state, { | ||
[key]: arrayToggle(state[key], items) | ||
}; | ||
}); | ||
}; | ||
@@ -271,5 +268,5 @@ }, | ||
return function (state) { | ||
return { ...state, | ||
return Object.assign({}, state, { | ||
[key]: arrayUpdate(state[key], predicateOrIds, obj) | ||
}; | ||
}); | ||
}; | ||
@@ -282,3 +279,3 @@ }, | ||
}; | ||
}); | ||
} | ||
@@ -285,0 +282,0 @@ function arrayAdd(arr, items) { |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Store = {}, global.Rx, global.Rx)); | ||
}(this, (function (exports, rxjs, operators) { 'use strict'; | ||
})(this, (function (exports, rxjs, operators) { 'use strict'; | ||
@@ -89,3 +89,5 @@ /*! ***************************************************************************** | ||
var Store = function (_super) { | ||
var Store = | ||
/** @class */ | ||
function (_super) { | ||
__extends(Store, _super); | ||
@@ -155,3 +157,3 @@ | ||
return new rxjs.Observable(function (observer) { | ||
var _loop_1 = function (key, query) { | ||
var _loop_1 = function _loop_1(key, query) { | ||
observer.add(query.subscribe(function (value) { | ||
@@ -232,3 +234,3 @@ buffer[key] = value; | ||
} | ||
var asap = function () { | ||
var asap = function asap() { | ||
return operators.debounceTime(0, rxjs.asapScheduler); | ||
@@ -267,3 +269,3 @@ }; | ||
var normalizedKey = capitalize(key); | ||
return _b = {}, _b["with" + normalizedKey] = function (value) { | ||
return _b = {}, _b["with".concat(normalizedKey)] = function (value) { | ||
var _a; | ||
@@ -279,3 +281,3 @@ | ||
}; | ||
}, _b["set" + normalizedKey] = function (value) { | ||
}, _b["set".concat(normalizedKey)] = function (value) { | ||
return function (state) { | ||
@@ -292,3 +294,3 @@ var _a; | ||
}; | ||
}, _b["update" + normalizedKey] = function (value) { | ||
}, _b["update".concat(normalizedKey)] = function (value) { | ||
return function (state) { | ||
@@ -305,3 +307,3 @@ var _a; | ||
}; | ||
}, _b["reset" + normalizedKey] = function () { | ||
}, _b["reset".concat(normalizedKey)] = function () { | ||
return function (state) { | ||
@@ -312,7 +314,7 @@ var _a; | ||
}; | ||
}, _b["select" + normalizedKey] = function () { | ||
}, _b["select".concat(normalizedKey)] = function () { | ||
return select(function (state) { | ||
return state[key]; | ||
}); | ||
}, _b["get" + normalizedKey] = function (state) { | ||
}, _b["get".concat(normalizedKey)] = function (state) { | ||
return state[key]; | ||
@@ -327,3 +329,3 @@ }, _b; | ||
var base = propsFactory(key, options); | ||
return __assign(__assign({}, base), (_a = {}, _a["add" + normalizedKey] = function (items) { | ||
return __assign(__assign({}, base), (_a = {}, _a["add".concat(normalizedKey)] = function (items) { | ||
return function (state) { | ||
@@ -334,3 +336,3 @@ var _a; | ||
}; | ||
}, _a["remove" + normalizedKey] = function (items) { | ||
}, _a["remove".concat(normalizedKey)] = function (items) { | ||
return function (state) { | ||
@@ -341,3 +343,3 @@ var _a; | ||
}; | ||
}, _a["toggle" + normalizedKey] = function (items) { | ||
}, _a["toggle".concat(normalizedKey)] = function (items) { | ||
return function (state) { | ||
@@ -348,3 +350,3 @@ var _a; | ||
}; | ||
}, _a["update" + normalizedKey] = function (predicateOrIds, obj) { | ||
}, _a["update".concat(normalizedKey)] = function (predicateOrIds, obj) { | ||
return function (state) { | ||
@@ -355,3 +357,3 @@ var _a; | ||
}; | ||
}, _a["in" + normalizedKey] = function (item) { | ||
}, _a["in".concat(normalizedKey)] = function (item) { | ||
return function (state) { | ||
@@ -363,3 +365,3 @@ return inArray(state[key], item); | ||
function arrayAdd(arr, items) { | ||
return __spreadArray(__spreadArray([], arr), coerceArray(items)); | ||
return __spreadArray(__spreadArray([], arr, true), coerceArray(items)); | ||
} | ||
@@ -445,2 +447,2 @@ function arrayRemove(arr, items) { | ||
}))); | ||
})); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
31809
748
0