vue-computed-eager 1.0.2 → 1.0.4

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 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -12,7 +12,6 @@
12
12
  <a href="https://github.com/vuefrag/vue-computed-eager/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-computed-eager.svg" alt="license" /></a>
13
13
  </p>
14
14
 
15
- > Extracted from [VueUse](https://vueuse.org/) for standalone use.
16
15
 
17
16
  ## Installation
18
17
 
@@ -23,35 +22,29 @@ npm install vue-computed-eager
23
22
  ## Usage
24
23
 
25
24
  ```ts
26
- import { computedEager } from 'vue-computed-eager';
27
- ```
28
-
29
- Eager computed without lazy evaluation.
30
-
31
- > **Info:** This function will be removed in future version.
32
-
33
-
34
- > **Tip:** Note💡: If you are using Vue 3.4+, you can use `computed` right away, you no longer need this function.
35
- In Vue 3.4+, if the computed new value does not change, `computed`, `effect`, `watch`, `watchEffect`, `render` dependencies will not be triggered.
36
- See: https://github.com/vuejs/core/pull/5912
37
-
38
-
39
- Learn more at [Vue: When a computed property can be the wrong tool](https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j).
40
-
41
- - Use `computed()` when you have a complex calculation going on, which can actually profit from caching and lazy evaluation and should only be (re-)calculated if really necessary.
42
- - Use `computedEager()` when you have a simple operation, with a rarely changing return value – often a boolean.
43
-
44
- ```ts
25
+ import { ref } from 'vue'
45
26
  import { computedEager } from 'vue-computed-eager'
46
27
 
47
28
  const todos = ref([])
48
29
  const hasOpenTodos = computedEager(() => !!todos.length)
49
30
 
50
31
  console.log(hasOpenTodos.value) // false
51
- toTodos.value.push({ title: 'Learn Vue' })
32
+ todos.value.push({ title: 'Learn Vue' })
52
33
  console.log(hasOpenTodos.value) // true
53
34
  ```
54
35
 
36
+ ## When to use
37
+
38
+ - Use `computed()` when you have a complex calculation that profits from caching and lazy evaluation.
39
+ - Use `computedEager()` when you have a simple operation with a rarely changing return value (often a boolean).
40
+
41
+ Learn more: [Vue: When a computed property can be the wrong tool](https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j)
42
+
43
+ **Note:** If you are using Vue 3.4+, standard `computed` has been optimized to avoid triggering effects when the value hasn't changed. See [vuejs/core#5912](https://github.com/vuejs/core/pull/5912).
44
+
45
+ > Extracted from [VueUse](https://vueuse.org/) for standalone use.
46
+
47
+
55
48
  ## License
56
49
 
57
50
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-computed-eager",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Vue 3 eager computed that evaluates immediately on dependency change",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",