@spoosh/plugin-prefetch 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 CHANGED
@@ -35,7 +35,7 @@ await prefetch((api) => api.posts.$get({ query: { page: 1, limit: 10 } }));
35
35
 
36
36
  // Prefetch with plugin options (staleTime, retries, etc.)
37
37
  await prefetch(
38
- (api) => api.users[userId].$get(),
38
+ (api) => api.users(userId).$get(),
39
39
  {
40
40
  staleTime: 60000,
41
41
  retries: 3,
@@ -45,7 +45,7 @@ await prefetch(
45
45
  // Prefetch on hover
46
46
  <Link
47
47
  href="/posts/1"
48
- onMouseEnter={() => prefetch((api) => api.posts[1].$get())}
48
+ onMouseEnter={() => prefetch((api) => api.posts(1).$get())}
49
49
  >
50
50
  View Post
51
51
  </Link>
@@ -55,8 +55,8 @@ await prefetch(
55
55
 
56
56
  ### Plugin Config
57
57
 
58
- | Option | Type | Default | Description |
59
- | ---------------- | -------- | ------- | ----------------------------------------------------------------- |
58
+ | Option | Type | Default | Description |
59
+ | ----------- | -------- | ------- | ----------------------------------------------------------------- |
60
60
  | `staleTime` | `number` | - | Default stale time for prefetched data (ms) |
61
61
  | `timeout` | `number` | `30000` | Timeout to auto-clear stale promises (ms). Prevents memory leaks. |
62
62
 
package/dist/index.d.mts CHANGED
@@ -39,9 +39,17 @@ declare module "@spoosh/core" {
39
39
  *
40
40
  * @example
41
41
  * ```ts
42
- * // Setup
43
- * const plugins = [prefetchPlugin(), cachePlugin(), retryPlugin()];
44
- * const { prefetch } = createReactSpoosh(spoosh);
42
+ * import { Spoosh } from "@spoosh/core";
43
+ *
44
+ * const client = new Spoosh<ApiSchema, Error>("/api")
45
+ * .use([
46
+ * // ... other plugins
47
+ * prefetchPlugin(),
48
+ * cachePlugin(),
49
+ * retryPlugin(),
50
+ * ]);
51
+ *
52
+ * const { prefetch } = createReactSpoosh(client);
45
53
  *
46
54
  * // Basic prefetch
47
55
  * await prefetch((api) => api.posts.$get());
@@ -50,7 +58,7 @@ declare module "@spoosh/core" {
50
58
  * await prefetch((api) => api.posts.$get({ query: { page: 1, limit: 10 } }));
51
59
  *
52
60
  * // Prefetch with plugin options (staleTime, retries, etc.)
53
- * await prefetch((api) => api.users[userId].$get(), {
61
+ * await prefetch((api) => api.users(userId).$get(), {
54
62
  * staleTime: 60000,
55
63
  * retries: 3,
56
64
  * });
@@ -58,7 +66,7 @@ declare module "@spoosh/core" {
58
66
  * // Prefetch on hover
59
67
  * <Link
60
68
  * href="/posts/1"
61
- * onMouseEnter={() => prefetch((api) => api.posts[1].$get())}
69
+ * onMouseEnter={() => prefetch((api) => api.posts(1).$get())}
62
70
  * >
63
71
  * View Post
64
72
  * </Link>
package/dist/index.d.ts CHANGED
@@ -39,9 +39,17 @@ declare module "@spoosh/core" {
39
39
  *
40
40
  * @example
41
41
  * ```ts
42
- * // Setup
43
- * const plugins = [prefetchPlugin(), cachePlugin(), retryPlugin()];
44
- * const { prefetch } = createReactSpoosh(spoosh);
42
+ * import { Spoosh } from "@spoosh/core";
43
+ *
44
+ * const client = new Spoosh<ApiSchema, Error>("/api")
45
+ * .use([
46
+ * // ... other plugins
47
+ * prefetchPlugin(),
48
+ * cachePlugin(),
49
+ * retryPlugin(),
50
+ * ]);
51
+ *
52
+ * const { prefetch } = createReactSpoosh(client);
45
53
  *
46
54
  * // Basic prefetch
47
55
  * await prefetch((api) => api.posts.$get());
@@ -50,7 +58,7 @@ declare module "@spoosh/core" {
50
58
  * await prefetch((api) => api.posts.$get({ query: { page: 1, limit: 10 } }));
51
59
  *
52
60
  * // Prefetch with plugin options (staleTime, retries, etc.)
53
- * await prefetch((api) => api.users[userId].$get(), {
61
+ * await prefetch((api) => api.users(userId).$get(), {
54
62
  * staleTime: 60000,
55
63
  * retries: 3,
56
64
  * });
@@ -58,7 +66,7 @@ declare module "@spoosh/core" {
58
66
  * // Prefetch on hover
59
67
  * <Link
60
68
  * href="/posts/1"
61
- * onMouseEnter={() => prefetch((api) => api.posts[1].$get())}
69
+ * onMouseEnter={() => prefetch((api) => api.posts(1).$get())}
62
70
  * >
63
71
  * View Post
64
72
  * </Link>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-prefetch",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Prefetch plugin for Spoosh - preload data before it's needed",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,11 +33,11 @@
33
33
  }
34
34
  },
35
35
  "peerDependencies": {
36
- "@spoosh/core": ">=0.2.0"
36
+ "@spoosh/core": ">=0.4.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@spoosh/core": "0.2.0",
40
- "@spoosh/test-utils": "0.1.1"
39
+ "@spoosh/core": "0.4.0",
40
+ "@spoosh/test-utils": "0.1.4"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "tsup --watch",