Skip to content

Commit

Permalink
release: v2.0.0-beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
runkids committed Nov 30, 2022
1 parent 8a3b723 commit 20e48dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions README-zh_TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ mutate(newData)
- 第二種:使用 callback function,會接受一個深拷貝的 `data` 資料,修改完後再返回結果

```js
const finalData = mutate((currentData) => {
currentData[0].name = 'runkids'
return currentData
const finalData = mutate((draft) => {
draft[0].name = 'runkids'
return draft
})

console.log(finalData[0]name === data.value[0].name) //true
Expand All @@ -409,9 +409,9 @@ async function updateUserName (userId, newName, rowIndex = 0) {
// 沒作用! 因為 `data` 是唯讀不可修改的.

// Easy to use function will receive deep clone data, and return updated data.
mutate(currentData => {
currentData[rowIndex] = response.data
return currentData
mutate(draft => {
draft[rowIndex] = response.data
return draft
})

console.log(data.value) //after: [{ id: 1, name: 'mutate name' }, { id: 2, name: 'vuejs' }]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ mutate(newData)
- Second way, use function will receive deep clone data, and return updated data.

```js
const finalData = mutate((currentData) => {
currentData[0].name = 'runkids'
return currentData
const finalData = mutate((draft) => {
draft[0].name = 'runkids'
return draft
})

console.log(finalData[0]name === data.value[0].name) //true
Expand All @@ -398,9 +398,9 @@ async function updateUserName (userId, newName, rowIndex = 0) {
// Not work! Because `data` is read only.

// Easy to use function will receive deep clone data, and return updated data.
mutate(currentData => {
currentData[rowIndex] = response.data
return currentData
mutate(draft => {
draft[rowIndex] = response.data
return draft
})

console.log(data.value) //after: [{ id: 1, name: 'mutate name' }, { id: 2, name: 'vuejs' }]
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-condition-watcher-core",
"version": "0.0.1",
"version": "0.0.2",
"main": "./dist/index.js",
"module": "./dist/index.esm.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-condition-watcher",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "Vue composition API for automatic data fetching. With conditions as the core. Easily control and sync to URL query string by conditions",
"main": "./core/dist/index.js",
"module": "./core/dist/index.esm.js",
Expand Down

0 comments on commit 20e48dd

Please sign in to comment.