floppy-disk 2.12.1 → 2.12.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.
@@ -39,7 +39,7 @@ export type QueryState<TKey extends StoreKey = StoreKey, TResponse = any, TData
39
39
  *
40
40
  * @returns function to revert the changes & function to invalidate the query
41
41
  *
42
- * IMPORTANT NOTE: This won't work well on infinite query.
42
+ * **IMPORTANT NOTE:** This won't work well on infinite query.
43
43
  */
44
44
  optimisticUpdate: (response: TResponse | ((prevState: QueryState<TKey, TResponse, TData, TError, TPageParam>) => TResponse)) => {
45
45
  revert: () => void;
@@ -233,11 +233,15 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
233
233
  };
234
234
  export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown, TPageParam = any> = UseStores<TKey, QueryState<TKey, TResponse, TData, TError, TPageParam>> & {
235
235
  /**
236
+ * ⚛️ (**_Hook_**)
237
+ *
236
238
  * Set query's initial response.
237
239
  *
238
240
  * This is used for server-side rendered page or static page.
239
241
  *
240
- * IMPORTANT NOTE: Put this on the root component or parent component, before any component subscribed!
242
+ * **IMPORTANT NOTE:**
243
+ * - This is a hook, put it inside of a React component
244
+ * - Put this on the root component or parent component, before any component subscribed!
241
245
  */
242
246
  setInitialResponse: (options: {
243
247
  key?: Maybe<TKey>;
@@ -265,7 +269,7 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
265
269
  *
266
270
  * @returns function to revert the changes & function to invalidate the query
267
271
  *
268
- * IMPORTANT NOTE: This won't work well on infinite query.
272
+ * **IMPORTANT NOTE:** This won't work well on infinite query.
269
273
  */
270
274
  optimisticUpdate: (options: {
271
275
  key?: Maybe<TKey>;
@@ -275,7 +279,12 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
275
279
  invalidate: () => void;
276
280
  };
277
281
  /**
282
+ * ⚛️ (**_Hook_**)
283
+ *
278
284
  * Use query with suspense mode.
285
+ *
286
+ * **IMPORTANT NOTE:**
287
+ * - This is a hook, put it inside of a React component
279
288
  */
280
289
  suspend: (key?: Maybe<TKey>) => Extract<QueryState<TKey, TResponse, TData, TError, TPageParam>, {
281
290
  status: 'success';
@@ -8,7 +8,7 @@ export type UseStore<T extends StoreData> = {
8
8
  * @param selectDeps A function that return the dependency array (just like in `useEffect`), to trigger reactivity.
9
9
  * Defaults to `undefined` (reactive to all state change) if you didn't set `defaultDeps` on `createStore`.
10
10
  *
11
- * IMPORTANT NOTE: `selectDeps` must not be changed after initialization.
11
+ * **IMPORTANT NOTE:** `selectDeps` must not be changed after initialization.
12
12
  */
13
13
  (selectDeps?: SelectDeps<T>): T;
14
14
  get: () => T;
@@ -16,9 +16,13 @@ export type UseStore<T extends StoreData> = {
16
16
  subscribe: (fn: (state: T) => void, selectDeps?: SelectDeps<T>) => () => void;
17
17
  getSubscribers: () => Subscribers<T>;
18
18
  /**
19
- * Set default values inside a component.
19
+ * ⚛️ (**_Hook_**)
20
20
  *
21
- * IMPORTANT NOTE: Put this on the root component or parent component, before any component subscribed!
21
+ * Set default values **inside of a component**.
22
+ *
23
+ * **IMPORTANT NOTE:**
24
+ * - This is a hook, put it inside of a React component
25
+ * - Put this on the root component or parent component, before any component subscribed!
22
26
  */
23
27
  setDefaultValues: (values: SetStoreData<T>) => void;
24
28
  Watch: (props: WatchProps<T>) => any;
@@ -7,7 +7,7 @@ export const createStore = (initializer, options = {}) => {
7
7
  const { get, set, subscribe, getSubscribers } = initStore(initializer, options);
8
8
  const { defaultDeps } = options;
9
9
  /**
10
- * IMPORTANT NOTE: selectDeps function must not be changed after initialization.
10
+ * **IMPORTANT NOTE:** `selectDeps` function must not be changed after initialization.
11
11
  */
12
12
  const useStore = (selectDeps = defaultDeps) => {
13
13
  const [state, setState] = useState(get);
@@ -15,7 +15,7 @@ export type UseStores<TKey extends StoreKey = StoreKey, T extends StoreData = St
15
15
  * @param selectDeps A function that return the dependency array (just like in `useEffect`), to trigger reactivity.
16
16
  * Defaults to `undefined` (reactive to all state change) if you didn't set `defaultDeps` on `createStores`.
17
17
  *
18
- * IMPORTANT NOTE: `selectDeps` must not be changed after initialization.
18
+ * **IMPORTANT NOTE:** `selectDeps` must not be changed after initialization.
19
19
  */
20
20
  (...args: [Maybe<TKey>, SelectDeps<T>?] | [SelectDeps<T>?]): T;
21
21
  get: (key?: Maybe<TKey>) => T;
@@ -28,9 +28,13 @@ export type UseStores<TKey extends StoreKey = StoreKey, T extends StoreData = St
28
28
  getStore: (key?: Maybe<TKey>) => InitStoreReturn<T>;
29
29
  getStores: () => Map<string, InitStoreReturn<T>>;
30
30
  /**
31
- * Set default values inside a component.
31
+ * ⚛️ (**_Hook_**)
32
32
  *
33
- * IMPORTANT NOTE: Put this on the root component or parent component, before any component subscribed!
33
+ * Set default values **inside of a component**.
34
+ *
35
+ * **IMPORTANT NOTE:**
36
+ * - This is a hook, put it inside of a React component
37
+ * - Put this on the root component or parent component, before any component subscribed!
34
38
  */
35
39
  setDefaultValues: (key: Maybe<TKey>, values: SetStoreData<T>) => void;
36
40
  Watch: (props: WatchProps<T> & {
@@ -17,7 +17,7 @@ export const createStores = (initializer, options = {}) => {
17
17
  return stores.get(keyHash);
18
18
  };
19
19
  /**
20
- * IMPORTANT NOTE: selectDeps function must not be changed after initialization.
20
+ * **IMPORTANT NOTE:** `selectDeps` function must not be changed after initialization.
21
21
  */
22
22
  const useStores = (...args) => {
23
23
  const [_key, selectDeps = defaultDeps] = (typeof args[0] === 'function' ? [{}, args[0]] : args);
@@ -39,7 +39,7 @@ export type QueryState<TKey extends StoreKey = StoreKey, TResponse = any, TData
39
39
  *
40
40
  * @returns function to revert the changes & function to invalidate the query
41
41
  *
42
- * IMPORTANT NOTE: This won't work well on infinite query.
42
+ * **IMPORTANT NOTE:** This won't work well on infinite query.
43
43
  */
44
44
  optimisticUpdate: (response: TResponse | ((prevState: QueryState<TKey, TResponse, TData, TError, TPageParam>) => TResponse)) => {
45
45
  revert: () => void;
@@ -233,11 +233,15 @@ export type CreateQueryOptions<TKey extends StoreKey = StoreKey, TResponse = any
233
233
  };
234
234
  export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown, TPageParam = any> = UseStores<TKey, QueryState<TKey, TResponse, TData, TError, TPageParam>> & {
235
235
  /**
236
+ * ⚛️ (**_Hook_**)
237
+ *
236
238
  * Set query's initial response.
237
239
  *
238
240
  * This is used for server-side rendered page or static page.
239
241
  *
240
- * IMPORTANT NOTE: Put this on the root component or parent component, before any component subscribed!
242
+ * **IMPORTANT NOTE:**
243
+ * - This is a hook, put it inside of a React component
244
+ * - Put this on the root component or parent component, before any component subscribed!
241
245
  */
242
246
  setInitialResponse: (options: {
243
247
  key?: Maybe<TKey>;
@@ -265,7 +269,7 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
265
269
  *
266
270
  * @returns function to revert the changes & function to invalidate the query
267
271
  *
268
- * IMPORTANT NOTE: This won't work well on infinite query.
272
+ * **IMPORTANT NOTE:** This won't work well on infinite query.
269
273
  */
270
274
  optimisticUpdate: (options: {
271
275
  key?: Maybe<TKey>;
@@ -275,7 +279,12 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
275
279
  invalidate: () => void;
276
280
  };
277
281
  /**
282
+ * ⚛️ (**_Hook_**)
283
+ *
278
284
  * Use query with suspense mode.
285
+ *
286
+ * **IMPORTANT NOTE:**
287
+ * - This is a hook, put it inside of a React component
279
288
  */
280
289
  suspend: (key?: Maybe<TKey>) => Extract<QueryState<TKey, TResponse, TData, TError, TPageParam>, {
281
290
  status: 'success';
@@ -8,7 +8,7 @@ export type UseStore<T extends StoreData> = {
8
8
  * @param selectDeps A function that return the dependency array (just like in `useEffect`), to trigger reactivity.
9
9
  * Defaults to `undefined` (reactive to all state change) if you didn't set `defaultDeps` on `createStore`.
10
10
  *
11
- * IMPORTANT NOTE: `selectDeps` must not be changed after initialization.
11
+ * **IMPORTANT NOTE:** `selectDeps` must not be changed after initialization.
12
12
  */
13
13
  (selectDeps?: SelectDeps<T>): T;
14
14
  get: () => T;
@@ -16,9 +16,13 @@ export type UseStore<T extends StoreData> = {
16
16
  subscribe: (fn: (state: T) => void, selectDeps?: SelectDeps<T>) => () => void;
17
17
  getSubscribers: () => Subscribers<T>;
18
18
  /**
19
- * Set default values inside a component.
19
+ * ⚛️ (**_Hook_**)
20
20
  *
21
- * IMPORTANT NOTE: Put this on the root component or parent component, before any component subscribed!
21
+ * Set default values **inside of a component**.
22
+ *
23
+ * **IMPORTANT NOTE:**
24
+ * - This is a hook, put it inside of a React component
25
+ * - Put this on the root component or parent component, before any component subscribed!
22
26
  */
23
27
  setDefaultValues: (values: SetStoreData<T>) => void;
24
28
  Watch: (props: WatchProps<T>) => any;
@@ -10,7 +10,7 @@ const createStore = (initializer, options = {}) => {
10
10
  const { get, set, subscribe, getSubscribers } = (0, vanilla_1.initStore)(initializer, options);
11
11
  const { defaultDeps } = options;
12
12
  /**
13
- * IMPORTANT NOTE: selectDeps function must not be changed after initialization.
13
+ * **IMPORTANT NOTE:** `selectDeps` function must not be changed after initialization.
14
14
  */
15
15
  const useStore = (selectDeps = defaultDeps) => {
16
16
  const [state, setState] = (0, react_1.useState)(get);
@@ -15,7 +15,7 @@ export type UseStores<TKey extends StoreKey = StoreKey, T extends StoreData = St
15
15
  * @param selectDeps A function that return the dependency array (just like in `useEffect`), to trigger reactivity.
16
16
  * Defaults to `undefined` (reactive to all state change) if you didn't set `defaultDeps` on `createStores`.
17
17
  *
18
- * IMPORTANT NOTE: `selectDeps` must not be changed after initialization.
18
+ * **IMPORTANT NOTE:** `selectDeps` must not be changed after initialization.
19
19
  */
20
20
  (...args: [Maybe<TKey>, SelectDeps<T>?] | [SelectDeps<T>?]): T;
21
21
  get: (key?: Maybe<TKey>) => T;
@@ -28,9 +28,13 @@ export type UseStores<TKey extends StoreKey = StoreKey, T extends StoreData = St
28
28
  getStore: (key?: Maybe<TKey>) => InitStoreReturn<T>;
29
29
  getStores: () => Map<string, InitStoreReturn<T>>;
30
30
  /**
31
- * Set default values inside a component.
31
+ * ⚛️ (**_Hook_**)
32
32
  *
33
- * IMPORTANT NOTE: Put this on the root component or parent component, before any component subscribed!
33
+ * Set default values **inside of a component**.
34
+ *
35
+ * **IMPORTANT NOTE:**
36
+ * - This is a hook, put it inside of a React component
37
+ * - Put this on the root component or parent component, before any component subscribed!
34
38
  */
35
39
  setDefaultValues: (key: Maybe<TKey>, values: SetStoreData<T>) => void;
36
40
  Watch: (props: WatchProps<T> & {
@@ -20,7 +20,7 @@ const createStores = (initializer, options = {}) => {
20
20
  return stores.get(keyHash);
21
21
  };
22
22
  /**
23
- * IMPORTANT NOTE: selectDeps function must not be changed after initialization.
23
+ * **IMPORTANT NOTE:** `selectDeps` function must not be changed after initialization.
24
24
  */
25
25
  const useStores = (...args) => {
26
26
  const [_key, selectDeps = defaultDeps] = (typeof args[0] === 'function' ? [{}, args[0]] : args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floppy-disk",
3
- "version": "2.12.1",
3
+ "version": "2.12.2",
4
4
  "description": "FloppyDisk - lightweight, simple, and powerful state management library",
5
5
  "keywords": [
6
6
  "state",