@spoosh/plugin-initial-data 0.1.1 → 0.1.3
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 +2 -3
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,16 +13,15 @@ npm install @spoosh/plugin-initial-data
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
+
import { Spoosh } from "@spoosh/core";
|
|
16
17
|
import { initialDataPlugin } from "@spoosh/plugin-initial-data";
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
+
const client = new Spoosh<ApiSchema, Error>("/api").use([initialDataPlugin()]);
|
|
19
20
|
|
|
20
|
-
// Show prefetched data immediately, then refetch in background
|
|
21
21
|
const { data, isInitialData } = useRead((api) => api.posts.$get(), {
|
|
22
22
|
initialData: prefetchedPosts,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
// Show initial data without background refetch
|
|
26
25
|
const { data } = useRead((api) => api.posts.$get(), {
|
|
27
26
|
initialData: prefetchedPosts,
|
|
28
27
|
refetchOnInitialData: false,
|
package/dist/index.d.mts
CHANGED
|
@@ -31,10 +31,13 @@ declare module "@spoosh/core" {
|
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
34
|
+
* import { Spoosh } from "@spoosh/core";
|
|
35
|
+
*
|
|
36
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
37
|
+
* .use([
|
|
38
|
+
* initialDataPlugin(),
|
|
39
|
+
* cachePlugin({ staleTime: 5000 }),
|
|
40
|
+
* ]);
|
|
38
41
|
*
|
|
39
42
|
* // Basic usage - shows initialData, refetches in background
|
|
40
43
|
* const { data, isInitialData } = useRead(
|
package/dist/index.d.ts
CHANGED
|
@@ -31,10 +31,13 @@ declare module "@spoosh/core" {
|
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
34
|
+
* import { Spoosh } from "@spoosh/core";
|
|
35
|
+
*
|
|
36
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
37
|
+
* .use([
|
|
38
|
+
* initialDataPlugin(),
|
|
39
|
+
* cachePlugin({ staleTime: 5000 }),
|
|
40
|
+
* ]);
|
|
38
41
|
*
|
|
39
42
|
* // Basic usage - shows initialData, refetches in background
|
|
40
43
|
* const { data, isInitialData } = useRead(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-initial-data",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Initial data plugin for Spoosh - show data immediately before fetch completes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@spoosh/core": ">=0.
|
|
36
|
+
"@spoosh/core": ">=0.4.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/core": "0.
|
|
40
|
-
"@spoosh/test-utils": "0.1.
|
|
39
|
+
"@spoosh/core": "0.4.0",
|
|
40
|
+
"@spoosh/test-utils": "0.1.4"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|