Skip to content

Commit fe356ec

Browse files
authored
docs: vars references (#953)
1 parent 465d222 commit fe356ec

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/docs/cookbook/composing-stores.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@ Composing stores is about having stores that use each other and there is one rul
55
If **two or more stores use each other**, they cannot create an infinite loop through _getters_ or _actions_. They cannot **both** directly read each other state in their setup function:
66

77
```js
8-
const useA = defineStore('a', () => {
9-
const b = useB()
8+
const useX = defineStore('x', () => {
9+
const y = useY()
1010

11-
//this is not possible because b also tries to read a.name
12-
b.name
11+
//This is not possible because y also tries to read x.name
12+
y.name
1313

1414
function doSomething() {
15-
// ✅ Read b properties in computed or actions
16-
const bName = b.name
15+
// ✅ Read y properties in computed or actions
16+
const yName = y.name
1717
// ...
1818
}
1919

2020
return {
21-
name: ref('I am A'),
21+
name: ref('I am X'),
2222
}
2323
})
2424

25-
const useB = defineStore('b', () => {
26-
const a = useA()
25+
const useY = defineStore('y', () => {
26+
const x = useX()
2727

28-
//this is not possible because a also tries to read a.name
29-
a.name
28+
//This is not possible because x also tries to read y.name
29+
x.name
3030

3131
function doSomething() {
32-
// ✅ Read b properties in computed or actions
33-
const aName = a.name
32+
// ✅ Read x properties in computed or actions
33+
const xName = x.name
3434
// ...
3535
}
3636

3737
return {
38-
name: ref('I am B'),
38+
name: ref('I am Y'),
3939
}
4040
})
4141
```

0 commit comments

Comments
 (0)