@flexbase/store
Advanced tools
@@ -8,3 +8,2 @@ import { StoreComparer } from '../core/store.comparer.js'; | ||
| key?: symbol; | ||
| defaultValue?: T; | ||
| comparer?: StoreComparer<T>; | ||
@@ -17,3 +16,2 @@ middleware?: StoreMiddleware<T>[]; | ||
| key(key: symbol | string): Omit<StoreOptionsFluent<T>, 'key'>; | ||
| defaultValue(value: T): Omit<StoreOptionsFluent<T>, 'defaultValue'>; | ||
| comparer(comparer: StoreComparer<T>): Omit<StoreOptionsFluent<T>, 'comparer'>; | ||
@@ -20,0 +18,0 @@ middleware(...middleware: StoreMiddleware<T>[]): Omit<StoreOptionsFluent<T>, 'middleware'>; |
@@ -15,5 +15,5 @@ import { Logger } from '@flexbase/logger'; | ||
| set logger(logger: Logger); | ||
| register<T>(key: symbol, default$: T | undefined, comparer: StoreComparer<T>, middleware: StoreMiddleware<T>[], persistanceProvider?: PersistanceProvider<T>): Store<T>; | ||
| register<T>(key: symbol, default$: T, comparer: StoreComparer<T>, middleware: StoreMiddleware<T>[], persistanceProvider?: PersistanceProvider<T>): Store<T>; | ||
| private executeAfterRegister; | ||
| getValue<T>(store: Store<T>): Readonly<T> | undefined; | ||
| getValue<T>(store: Store<T>): Readonly<T>; | ||
| private executeSetterCallback; | ||
@@ -20,0 +20,0 @@ private handlePersistance; |
@@ -1,2 +0,2 @@ | ||
| export type StoreComparer<T> = (newValue: T | undefined, currentValue: T | undefined) => boolean; | ||
| export declare const defaultStoreComparer: <T>(newValue: T | undefined, oldValue: T | undefined) => boolean; | ||
| export type StoreComparer<T> = (newValue: T, currentValue: T) => boolean; | ||
| export declare const defaultStoreComparer: <T>(newValue: T, oldValue: T) => boolean; |
| export interface StoreMiddlewareContext<T> { | ||
| newValue: T | undefined; | ||
| currentValue: T | undefined; | ||
| newValue: T; | ||
| currentValue: T; | ||
| } | ||
| export type StoreMiddlewareNext = () => Promise<void>; | ||
| export type StoreMiddleware<T> = (context: StoreMiddlewareContext<T>, next: StoreMiddlewareNext) => Promise<void>; |
@@ -1,2 +0,2 @@ | ||
| export type SetterCallback<T> = ((currentValue: Readonly<T> | undefined) => T | undefined) | (T | undefined); | ||
| export type SetterCallback<T> = ((currentValue: Readonly<T>) => T) | T; | ||
| export type Setter<T> = (setter: SetterCallback<T>) => Promise<void>; |
@@ -6,2 +6,2 @@ import { Store } from '../core/store.interface.js'; | ||
| */ | ||
| export declare const createStore: <T>(options?: StoreOptions<T> | ((builder: StoreOptionsFluent<T>) => void) | undefined) => Store<T>; | ||
| export declare const createStore: <T>(defaultValue: T, options?: StoreOptions<T> | ((builder: StoreOptionsFluent<T>) => void) | undefined) => Store<T>; |
| import { Store } from '../core/store.interface.js'; | ||
| export declare const getStoreValue: <T>(store: Store<T>) => Readonly<T> | undefined; | ||
| export declare const getStoreValue: <T>(store: Store<T>) => Readonly<T>; |
+20
-20
| var f = Object.defineProperty; | ||
| var y = (s, e, t) => e in s ? f(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t; | ||
| var i = (s, e, t) => (y(s, typeof e != "symbol" ? e + "" : e, t), t); | ||
| import { subjectManager as l, multicastDispatcher as v, noopSubscription as m } from "@flexbase/observable-subject"; | ||
| import { subjectManager as l, multicastDispatcher as m, noopSubscription as v } from "@flexbase/observable-subject"; | ||
| class k { | ||
@@ -78,3 +78,3 @@ async dispatch(e, t) { | ||
| const g = { key: e }, h = new b(e, t, r, a, g, n); | ||
| return this._stores.set(e, h), d.set(e, this), l.register(g, v), this.executeAfterRegister(h).then(() => { | ||
| return this._stores.set(e, h), d.set(e, this), l.register(g, m), this.executeAfterRegister(h).then(() => { | ||
| var u; | ||
@@ -98,4 +98,3 @@ (u = this._logger) == null || u.debug("executeAfterRegister finished"); | ||
| const a = `Value with key '${e.key.toString()}' has not been registered with this storage manager`; | ||
| (r = this._logger) == null || r.warn(a); | ||
| return; | ||
| throw (r = this._logger) == null || r.warn(a), new Error(a); | ||
| } | ||
@@ -153,3 +152,3 @@ return t.value; | ||
| const r = this._stores.get(e.key); | ||
| return r ? l.subscribe(r.subject, t) : ((a = this._logger) == null || a.warn(`Trying to subscribe to store '${e.key.toString()}' which has not been registered with this storage manager`), m); | ||
| return r ? l.subscribe(r.subject, t) : ((a = this._logger) == null || a.warn(`Trying to subscribe to store '${e.key.toString()}' which has not been registered with this storage manager`), v); | ||
| } | ||
@@ -160,3 +159,3 @@ static lookupManager(e) { | ||
| } | ||
| const V = new c(), P = (s, e) => s === e && Object.is(s, e); | ||
| const P = new c(), V = (s, e) => s === e && Object.is(s, e); | ||
| class j { | ||
@@ -232,5 +231,6 @@ constructor(e, t, r) { | ||
| } | ||
| defaultValue(e) { | ||
| return this._options.defaultValue = e, this; | ||
| } | ||
| // defaultValue(value: T): Omit<StoreOptionsFluent<T>, 'default'> { | ||
| // this._options.defaultValue = value; | ||
| // return this; | ||
| // } | ||
| comparer(e) { | ||
@@ -249,5 +249,5 @@ return this._options.comparer = e, this; | ||
| } | ||
| const U = (s) => { | ||
| const t = new M(s).build(), r = (t == null ? void 0 : t.storageManager) ?? V, a = (t == null ? void 0 : t.key) ?? Symbol(), n = (t == null ? void 0 : t.defaultValue) ?? void 0, o = (t == null ? void 0 : t.comparer) ?? P, g = (t == null ? void 0 : t.middleware) ?? [], h = t == null ? void 0 : t.persistanceProvider; | ||
| return r.register(a, n, o, g, h); | ||
| const U = (s, e) => { | ||
| const r = new M(e).build(), a = (r == null ? void 0 : r.storageManager) ?? P, n = (r == null ? void 0 : r.key) ?? Symbol(), o = (r == null ? void 0 : r.comparer) ?? V, g = (r == null ? void 0 : r.middleware) ?? [], h = r == null ? void 0 : r.persistanceProvider; | ||
| return a.register(n, s, o, g, h); | ||
| }, C = (s) => { | ||
@@ -258,3 +258,3 @@ const e = c.lookupManager(s); | ||
| return e.getValue(s); | ||
| }, x = (s, e) => { | ||
| }, E = (s, e) => { | ||
| const t = c.lookupManager(s); | ||
@@ -264,3 +264,3 @@ if (t === void 0) | ||
| return t.subscribe(s, e); | ||
| }, D = async (s, e) => { | ||
| }, x = async (s, e) => { | ||
| const t = c.lookupManager(s); | ||
@@ -270,3 +270,3 @@ if (t === void 0) | ||
| await t.setValue(s, e); | ||
| }, E = async (s) => { | ||
| }, D = async (s) => { | ||
| const e = c.lookupManager(s); | ||
@@ -286,10 +286,10 @@ if (e === void 0) | ||
| U as createStore, | ||
| P as defaultStoreComparer, | ||
| V as defaultStoreComparer, | ||
| S as defaultStoreDispatcher, | ||
| R as getStoreSetter, | ||
| C as getStoreValue, | ||
| E as resetStoreValue, | ||
| D as setStoreValue, | ||
| V as storageManager, | ||
| x as subscribeToStore | ||
| D as resetStoreValue, | ||
| x as setStoreValue, | ||
| P as storageManager, | ||
| E as subscribeToStore | ||
| }; |
+9
-3
| { | ||
| "name": "@flexbase/store", | ||
| "version": "2.0.3", | ||
| "version": "2.0.4-beta.8", | ||
| "description": "State management framework", | ||
@@ -12,3 +12,5 @@ "main": "./dist/index.js", | ||
| }, | ||
| "bugs": { "url": "https://github.com/flexbase-eng/store/issues" }, | ||
| "bugs": { | ||
| "url": "https://github.com/flexbase-eng/store/issues" | ||
| }, | ||
| "author": { | ||
@@ -25,3 +27,7 @@ "name": "Flexbase Technologies", | ||
| "type": "module", | ||
| "keywords": ["flexbase", "state management", "flux"] | ||
| "keywords": [ | ||
| "flexbase", | ||
| "state management", | ||
| "flux" | ||
| ] | ||
| } |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
22141
-0.77%430
-0.46%1
Infinity%