@nexcodepl/store
Advanced tools
+2
-2
@@ -1,2 +0,2 @@ | ||
| import { StoreConfig, StoreReadonly, StoreSetState, StoreSubscriber } from "./types.js"; | ||
| import { StoreConfig, StoreInitState, StoreReadonly, StoreSetState, StoreSubscriber } from "./types.js"; | ||
| export declare class Store<T> implements StoreReadonly<T> { | ||
@@ -6,3 +6,3 @@ protected _state: T; | ||
| protected _subscribersSet: Set<StoreSubscriber<T>>; | ||
| constructor(initState: T, config?: StoreConfig<T>); | ||
| constructor(initState: StoreInitState<T>, config?: StoreConfig<T>); | ||
| current(): Readonly<T>; | ||
@@ -9,0 +9,0 @@ subscribe(subscriber: StoreSubscriber<T>): () => void; |
+4
-1
@@ -7,3 +7,3 @@ import { compare } from "./compare.js"; | ||
| constructor(initState, config) { | ||
| this._state = initState; | ||
| this._state = isInitStateFunction(initState) ? initState() : initState; | ||
| this._config = config; | ||
@@ -60,1 +60,4 @@ this._subscribersSet = new Set(); | ||
| } | ||
| function isInitStateFunction(initState) { | ||
| return typeof initState === "function"; | ||
| } |
+2
-0
@@ -23,1 +23,3 @@ export type Primitive = string | number | boolean | bigint | symbol | undefined | null; | ||
| } | ||
| export type StoreInitStateFunction<T> = () => T; | ||
| export type StoreInitState<T> = T | StoreInitStateFunction<T>; |
+1
-1
| { | ||
| "name": "@nexcodepl/store", | ||
| "version": "1.0.14", | ||
| "version": "1.0.15", | ||
| "description": "State management library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
11970
2.39%282
1.81%