Skip to content

Commit 22f5ea5

Browse files
docs(website): vue computed solution
1 parent dcb0d02 commit 22f5ea5

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default () => [
2+
{
3+
fileName: 'components/SomeComponent.vue (template)',
4+
target: 'markup',
5+
code: `
6+
<div>
7+
{{ title }}
8+
</div>
9+
`,
10+
},
11+
{
12+
fileName: 'components/SomeComponent.vue (script)',
13+
code: `
14+
export default {
15+
props: ["id"],
16+
data: (self) => ({
17+
get title() {
18+
return self.state.titles[self.id]
19+
}
20+
})
21+
}
22+
`,
23+
},
24+
]

packages/overmind-website/guides/beginner/08_usingovermindwithvue.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,14 @@ To run effects in components based on changes to state you use the **addMutation
6969

7070
```marksy
7171
h(Example, { name: "guide/usingovermindwithvue/effect" })
72+
```
73+
74+
## Computed
75+
76+
Vue has its own observable concept that differs from Overmind. That means you can not use Overmind state inside a computed and expect the computed cache to be busted when the Overmind state changes. But computeds are really for caching expensive computation, which you will not do inside a component using Overmind anyways.
77+
78+
What you might want is to introduce some logic, maybe combine som data from props. You can do so using a getter on your **data**.
79+
80+
```marksy
81+
h(Example, { name: "guide/usingovermindwithvue/computed" })
7282
```

0 commit comments

Comments
 (0)