vue-computed-with-control 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +14 -26
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -18,32 +18,27 @@ import { computedWithControl } from 'vue-computed-with-control';
18
18
 
19
19
  Explicitly define the dependencies of computed.
20
20
 
21
- ```ts twoslash include main
22
- import { computedWithControl } from 'vue-computed-with-control'
21
+ ```ts
22
+ import { ref } from 'vue';
23
+ import { computedWithControl } from 'vue-computed-with-control';
23
24
 
24
- const source = ref('foo')
25
- const counter = ref(0)
25
+ const source = ref('foo');
26
+ const counter = ref(0);
26
27
 
27
28
  const computedRef = computedWithControl(
28
29
  () => source.value, // watch source, same as `watch`
29
30
  () => counter.value, // computed getter, same as `computed`
30
- )
31
- ```
32
-
33
- With this, the changes of `counter` won't trigger `computedRef` to update but the `source` ref does.
31
+ );
34
32
 
35
- ```ts
36
- // @include: main
37
- // ---cut---
38
- console.log(computedRef.value) // 0
33
+ console.log(computedRef.value); // 0
39
34
 
40
- counter.value += 1
35
+ counter.value += 1;
41
36
 
42
- console.log(computedRef.value) // 0
37
+ console.log(computedRef.value); // 0 (counter change doesn't trigger update)
43
38
 
44
- source.value = 'bar'
39
+ source.value = 'bar';
45
40
 
46
- console.log(computedRef.value) // 1
41
+ console.log(computedRef.value); // 1 (source change triggers update)
47
42
  ```
48
43
 
49
44
  ### Manual Triggering
@@ -51,14 +46,7 @@ console.log(computedRef.value) // 1
51
46
  You can also manually trigger the update of the computed by:
52
47
 
53
48
  ```ts
54
- // @include: main
55
- // ---cut---
56
- const computedRef = computedWithControl(
57
- () => source.value,
58
- () => counter.value,
59
- )
60
-
61
- computedRef.trigger()
49
+ computedRef.trigger();
62
50
  ```
63
51
 
64
52
  ### Deep Watch
@@ -67,13 +55,13 @@ Unlike `computed`, `computedWithControl` is shallow by default.
67
55
  You can specify the same options as `watch` to control the behavior:
68
56
 
69
57
  ```ts
70
- const source = ref({ name: 'foo' })
58
+ const source = ref({ name: 'foo' });
71
59
 
72
60
  const computedRef = computedWithControl(
73
61
  source,
74
62
  () => counter.value,
75
63
  { deep: true },
76
- )
64
+ );
77
65
  ```
78
66
 
79
67
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-computed-with-control",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Computed with manual control",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -44,4 +44,4 @@
44
44
  "typescript": "^5.0.0",
45
45
  "vue": "^3.4.0"
46
46
  }
47
- }
47
+ }