@webkrafters/react-observable-context 0.0.1 → 0.0.2
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 +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ The `useStore` returns the context `store` object for consuming the React-Observ
|
|
|
18
18
|
|
|
19
19
|
The context `store` exposes **4** methods for interacting with the context namely:
|
|
20
20
|
|
|
21
|
-
* **getState**: (selector?: (state: State) =>
|
|
21
|
+
* **getState**: (selector?: (state: State) => any) => any
|
|
22
22
|
|
|
23
23
|
* **resetState**: VoidFunction // resets the state to the Provider latest `value` prop.
|
|
24
24
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export type State = {
|
|
|
15
15
|
export type PartialState<T_1 extends State> = {
|
|
16
16
|
[x: string]: any;
|
|
17
17
|
} & { [K in keyof T]?: T[K]; };
|
|
18
|
-
export type Selector<T_1 extends State> = (state: T) =>
|
|
18
|
+
export type Selector<T_1 extends State> = (state: T) => any;
|
|
19
19
|
export type Store<T_1 extends State> = {
|
|
20
|
-
getState: (selector?: Selector<T>) =>
|
|
20
|
+
getState: (selector?: Selector<T>) => any;
|
|
21
21
|
resetState: OptionalTask<VoidFunction>;
|
|
22
22
|
setState: (changes: PartialState<T>) => void;
|
|
23
23
|
subscribe: (listener: Listener<T>) => Unsubscribe;
|
package/dist/index.js
CHANGED
|
@@ -157,26 +157,30 @@ Provider.displayName = 'ObservableContext.Provider';
|
|
|
157
157
|
*/
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
* @typedef {(newValue: PartialState<T>, oldValue: PartialState<T>) => void} Listener
|
|
161
|
+
* @template {State} T
|
|
162
162
|
*/
|
|
163
|
+
|
|
163
164
|
/** @typedef {{[x:string]: *}} State */
|
|
165
|
+
|
|
164
166
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
* @typedef {{[x:string]: *} & {[K in keyof T]?: T[K]}} PartialState
|
|
168
|
+
* @template {State} T
|
|
167
169
|
*/
|
|
170
|
+
|
|
168
171
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
* @typedef {(state: T) => *} Selector
|
|
173
|
+
* @template {State} T
|
|
171
174
|
*/
|
|
175
|
+
|
|
172
176
|
/**
|
|
173
177
|
* @typedef {{
|
|
174
|
-
* getState: OptionalTask<(selector?: Selector<T>) =>
|
|
178
|
+
* getState: OptionalTask<(selector?: Selector<T>) => *>,
|
|
175
179
|
* resetState: OptionalTask<VoidFunction>,
|
|
176
180
|
* setState: OptionalTask<(changes: PartialState<T>) => void>,
|
|
177
181
|
* subscribe: OptionalTask<(listener: Listener<T>) => Unsubscribe>
|
|
178
182
|
* }} Store
|
|
179
|
-
|
|
183
|
+
* @template {State} T
|
|
180
184
|
*/
|
|
181
185
|
|
|
182
186
|
/** @typedef {VoidFunction} Unsubscribe */
|
package/package.json
CHANGED