@spoosh/plugin-initial-data 0.2.0 → 0.2.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 +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Initial data plugin for Spoosh - show data immediately before fetch completes.
|
|
4
4
|
|
|
5
|
-
**[Documentation](https://spoosh.dev/docs/plugins/initial-data)** · **Requirements:** TypeScript >= 5.0 · **Peer Dependencies:** `@spoosh/core`
|
|
5
|
+
**[Documentation](https://spoosh.dev/docs/react/plugins/initial-data)** · **Requirements:** TypeScript >= 5.0 · **Peer Dependencies:** `@spoosh/core`
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -18,11 +18,11 @@ import { initialDataPlugin } from "@spoosh/plugin-initial-data";
|
|
|
18
18
|
|
|
19
19
|
const client = new Spoosh<ApiSchema, Error>("/api").use([initialDataPlugin()]);
|
|
20
20
|
|
|
21
|
-
const { data, isInitialData } = useRead((api) => api.
|
|
21
|
+
const { data, isInitialData } = useRead((api) => api("posts").GET(), {
|
|
22
22
|
initialData: prefetchedPosts,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
const { data } = useRead((api) => api.
|
|
25
|
+
const { data } = useRead((api) => api("posts").GET(), {
|
|
26
26
|
initialData: prefetchedPosts,
|
|
27
27
|
refetchOnInitialData: false,
|
|
28
28
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ declare module "@spoosh/core" {
|
|
|
25
25
|
* Initial data is shown immediately on first mount, before any fetch completes.
|
|
26
26
|
* By default, a background refetch is triggered to get fresh data.
|
|
27
27
|
*
|
|
28
|
-
* @see {@link https://spoosh.dev/docs/plugins/initial-data | Initial Data Plugin Documentation}
|
|
28
|
+
* @see {@link https://spoosh.dev/docs/react/plugins/initial-data | Initial Data Plugin Documentation}
|
|
29
29
|
*
|
|
30
30
|
* @returns Initial data plugin instance
|
|
31
31
|
*
|
|
@@ -41,13 +41,13 @@ declare module "@spoosh/core" {
|
|
|
41
41
|
*
|
|
42
42
|
* // Basic usage - shows initialData, refetches in background
|
|
43
43
|
* const { data, isInitialData } = useRead(
|
|
44
|
-
* (api) => api.
|
|
44
|
+
* (api) => api("posts").GET(),
|
|
45
45
|
* { initialData: prefetchedPosts }
|
|
46
46
|
* );
|
|
47
47
|
*
|
|
48
48
|
* // Disable background refetch
|
|
49
49
|
* const { data } = useRead(
|
|
50
|
-
* (api) => api.
|
|
50
|
+
* (api) => api("posts").GET(),
|
|
51
51
|
* { initialData: prefetchedPosts, refetchOnInitialData: false }
|
|
52
52
|
* );
|
|
53
53
|
* ```
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare module "@spoosh/core" {
|
|
|
25
25
|
* Initial data is shown immediately on first mount, before any fetch completes.
|
|
26
26
|
* By default, a background refetch is triggered to get fresh data.
|
|
27
27
|
*
|
|
28
|
-
* @see {@link https://spoosh.dev/docs/plugins/initial-data | Initial Data Plugin Documentation}
|
|
28
|
+
* @see {@link https://spoosh.dev/docs/react/plugins/initial-data | Initial Data Plugin Documentation}
|
|
29
29
|
*
|
|
30
30
|
* @returns Initial data plugin instance
|
|
31
31
|
*
|
|
@@ -41,13 +41,13 @@ declare module "@spoosh/core" {
|
|
|
41
41
|
*
|
|
42
42
|
* // Basic usage - shows initialData, refetches in background
|
|
43
43
|
* const { data, isInitialData } = useRead(
|
|
44
|
-
* (api) => api.
|
|
44
|
+
* (api) => api("posts").GET(),
|
|
45
45
|
* { initialData: prefetchedPosts }
|
|
46
46
|
* );
|
|
47
47
|
*
|
|
48
48
|
* // Disable background refetch
|
|
49
49
|
* const { data } = useRead(
|
|
50
|
-
* (api) => api.
|
|
50
|
+
* (api) => api("posts").GET(),
|
|
51
51
|
* { initialData: prefetchedPosts, refetchOnInitialData: false }
|
|
52
52
|
* );
|
|
53
53
|
* ```
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-initial-data",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Initial data plugin for Spoosh - show data immediately before fetch completes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/spooshdev/spoosh.git",
|
|
9
9
|
"directory": "packages/plugin-initial-data"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/spooshdev/spoosh/issues"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://spoosh.dev/react/
|
|
14
|
+
"homepage": "https://spoosh.dev/docs/react/plugins/initial-data",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@spoosh/core": ">=0.4.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/core": "0.
|
|
39
|
+
"@spoosh/core": "0.10.0",
|
|
40
40
|
"@spoosh/test-utils": "0.1.5"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|