@slimlib/store 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,9 +95,9 @@ $storeName
95
95
 
96
96
  The only exported function. It returns createStore factory (see next) which notifies innidiately after creating store if `notifyAfterCreation` is truethy.
97
97
 
98
- #### `createStore<T>(initialState: T): [T, Store<T>]`
98
+ #### `createStore<T>(initialState: T): [T, Store<T>, () => void]`
99
99
 
100
- Store factory function that takes initial state and returns proxy object and store tuple. Proxy object ment to be left for actions implementations and store is for subscription for changes.
100
+ Store factory function that takes initial state and returns proxy object, store and function to notify subscribers. Proxy object ment to be left for actions implementations, store is for subscription for changes and notification only for some edge cases when original object have been changed and listeners have to be notified.
101
101
 
102
102
  #### `unwrapValue(value: T): T`
103
103
 
@@ -118,7 +118,7 @@ Publish/subscribe/read pattern implementation. Ment to be used in components / s
118
118
 
119
119
  ### `react` and `preact` exports
120
120
 
121
- #### `createStore<T>(initialState: T): [T, Store<T>]`
121
+ #### `createStore<T>(initialState: T): [T, Store<T>, () => void]`
122
122
 
123
123
  Store factory created with `notifyAfterCreation` === `false`.
124
124
 
@@ -128,7 +128,7 @@ Function to subscribe to store inside component. Returns current state.
128
128
 
129
129
  ### `svelte` export
130
130
 
131
- #### `createStore<T>(initialState: T): [T, Store<T>]`
131
+ #### `createStore<T>(initialState: T): [T, Store<T>, () => void]`
132
132
 
133
133
  Store factory created with `notifyAfterCreation` === `true`.
134
134
 
package/dist/core.cjs CHANGED
@@ -61,7 +61,8 @@ const createStoreFactory = (notifyAfterCreation) => {
61
61
  cb(object);
62
62
  }
63
63
  return () => storeListeners.delete(cb);
64
- })
64
+ }),
65
+ enqueueNotification
65
66
  ];
66
67
  function createProxy(object) {
67
68
  if (proxiesCache.has(object)) {
package/dist/core.d.ts CHANGED
@@ -5,4 +5,4 @@ export interface Store<T> {
5
5
  (): Readonly<T>;
6
6
  }
7
7
  export declare const unwrapValue: <T>(value: T) => T;
8
- export declare const createStoreFactory: (notifyAfterCreation: boolean) => <T extends object>(object?: T) => [T, Store<T>];
8
+ export declare const createStoreFactory: (notifyAfterCreation: boolean) => <T extends object>(object?: T) => [T, Store<T>, () => void];
package/dist/core.mjs CHANGED
@@ -57,7 +57,8 @@ const createStoreFactory = (notifyAfterCreation) => {
57
57
  cb(object);
58
58
  }
59
59
  return () => storeListeners.delete(cb);
60
- })
60
+ }),
61
+ enqueueNotification
61
62
  ];
62
63
  function createProxy(object) {
63
64
  if (proxiesCache.has(object)) {
package/dist/preact.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { Store } from './core';
2
- export declare const createStore: <T extends object>(object?: T) => [T, Store<T>];
2
+ export declare const createStore: <T extends object>(object?: T) => [T, Store<T>, () => void];
3
3
  export declare const useStore: <T>(store: Store<T>) => Readonly<T>;
package/dist/react.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { Store } from './core';
2
- export declare const createStore: <T extends object>(object?: T) => [T, Store<T>];
2
+ export declare const createStore: <T extends object>(object?: T) => [T, Store<T>, () => void];
3
3
  export declare const useStore: <T>(store: Store<T>) => Readonly<T>;
package/dist/svelte.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const createStore: <T extends object>(object?: T) => [T, import("./core").Store<T>];
1
+ export declare const createStore: <T extends object>(object?: T) => [T, import("./core").Store<T>, () => void];
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.0",
2
+ "version": "1.3.0",
3
3
  "license": "MIT",
4
4
  "name": "@slimlib/store",
5
5
  "author": "Konstantin Shutkin",