@spoosh/plugin-optimistic 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
@@ -18,12 +18,16 @@ Note: This plugin requires `@spoosh/plugin-invalidation` as a peer dependency.
18
18
  ## Usage
19
19
 
20
20
  ```typescript
21
+ import { Spoosh } from "@spoosh/core";
21
22
  import { optimisticPlugin } from "@spoosh/plugin-optimistic";
22
23
  import { invalidationPlugin } from "@spoosh/plugin-invalidation";
23
24
 
24
- const plugins = [invalidationPlugin(), optimisticPlugin()] as const;
25
+ const client = new Spoosh<ApiSchema, Error>("/api").use([
26
+ invalidationPlugin(),
27
+ optimisticPlugin(),
28
+ ]);
25
29
 
26
- const { trigger } = useWrite((api) => api.posts[id].$delete);
30
+ const { trigger } = useWrite((api) => api.posts(id).$delete);
27
31
 
28
32
  trigger({
29
33
  // Optimistic delete - instantly remove item from list
package/dist/index.d.mts CHANGED
@@ -53,7 +53,13 @@ declare const OPTIMISTIC_SNAPSHOTS_KEY = "optimistic:snapshots";
53
53
  *
54
54
  * @example
55
55
  * ```ts
56
- * const plugins = [optimisticPlugin()];
56
+ * import { Spoosh } from "@spoosh/core";
57
+ *
58
+ * const client = new Spoosh<ApiSchema, Error>("/api")
59
+ * .use([
60
+ * // ... other plugins
61
+ * optimisticPlugin(),
62
+ * ]);
57
63
  *
58
64
  * // In useWrite - autoInvalidate defaults to "none" when optimistic is used
59
65
  * trigger({
package/dist/index.d.ts CHANGED
@@ -53,7 +53,13 @@ declare const OPTIMISTIC_SNAPSHOTS_KEY = "optimistic:snapshots";
53
53
  *
54
54
  * @example
55
55
  * ```ts
56
- * const plugins = [optimisticPlugin()];
56
+ * import { Spoosh } from "@spoosh/core";
57
+ *
58
+ * const client = new Spoosh<ApiSchema, Error>("/api")
59
+ * .use([
60
+ * // ... other plugins
61
+ * optimisticPlugin(),
62
+ * ]);
57
63
  *
58
64
  * // In useWrite - autoInvalidate defaults to "none" when optimistic is used
59
65
  * trigger({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-optimistic",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Optimistic updates plugin for Spoosh - instant UI updates with automatic rollback",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,13 +33,13 @@
33
33
  }
34
34
  },
35
35
  "peerDependencies": {
36
- "@spoosh/core": ">=0.2.0",
37
- "@spoosh/plugin-invalidation": ">=0.1.0"
36
+ "@spoosh/core": ">=0.4.0",
37
+ "@spoosh/plugin-invalidation": ">=1.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@spoosh/core": "0.2.0",
41
- "@spoosh/plugin-invalidation": "0.1.1",
42
- "@spoosh/test-utils": "0.1.1"
40
+ "@spoosh/core": "0.4.0",
41
+ "@spoosh/plugin-invalidation": "0.1.3",
42
+ "@spoosh/test-utils": "0.1.4"
43
43
  },
44
44
  "scripts": {
45
45
  "dev": "tsup --watch",