@spoosh/plugin-polling 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 +3 -2
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,9 +13,10 @@ npm install @spoosh/plugin-polling
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
+
import { Spoosh } from "@spoosh/core";
|
|
16
17
|
import { pollingPlugin } from "@spoosh/plugin-polling";
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
+
const client = new Spoosh<ApiSchema, Error>("/api").use([pollingPlugin()]);
|
|
19
20
|
|
|
20
21
|
// Static polling interval (5 seconds)
|
|
21
22
|
useRead((api) => api.posts.$get(), { pollingInterval: 5000 });
|
|
@@ -24,7 +25,7 @@ useRead((api) => api.posts.$get(), { pollingInterval: 5000 });
|
|
|
24
25
|
useRead((api) => api.posts.$get(), { pollingInterval: false });
|
|
25
26
|
|
|
26
27
|
// Dynamic polling interval based on data/error
|
|
27
|
-
useRead((api) => api.booking
|
|
28
|
+
useRead((api) => api.booking(123).$get(), {
|
|
28
29
|
pollingInterval: (data, error) => {
|
|
29
30
|
if (error) return 10000; // Slower polling on error
|
|
30
31
|
if (data?.status === "pending") return 1000; // Fast polling for pending
|
package/dist/index.d.mts
CHANGED
|
@@ -27,7 +27,13 @@ declare module "@spoosh/core" {
|
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```ts
|
|
30
|
-
*
|
|
30
|
+
* import { Spoosh } from "@spoosh/core";
|
|
31
|
+
*
|
|
32
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
33
|
+
* .use([
|
|
34
|
+
* // ... other plugins
|
|
35
|
+
* pollingPlugin(),
|
|
36
|
+
* ]);
|
|
31
37
|
*
|
|
32
38
|
* // Poll every 5 seconds
|
|
33
39
|
* useRead((api) => api.posts.$get(), {
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,13 @@ declare module "@spoosh/core" {
|
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```ts
|
|
30
|
-
*
|
|
30
|
+
* import { Spoosh } from "@spoosh/core";
|
|
31
|
+
*
|
|
32
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
33
|
+
* .use([
|
|
34
|
+
* // ... other plugins
|
|
35
|
+
* pollingPlugin(),
|
|
36
|
+
* ]);
|
|
31
37
|
*
|
|
32
38
|
* // Poll every 5 seconds
|
|
33
39
|
* useRead((api) => api.posts.$get(), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-polling",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Automatic polling/refetching plugin for Spoosh",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@spoosh/core": ">=0.
|
|
37
|
+
"@spoosh/core": ">=0.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@spoosh/core": "0.
|
|
41
|
-
"@spoosh/test-utils": "0.1.
|
|
40
|
+
"@spoosh/core": "0.4.0",
|
|
41
|
+
"@spoosh/test-utils": "0.1.4"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"dev": "tsup --watch",
|