Skip to content

Commit 9993d67

Browse files
Merge pull request cerebral#208 from cerebral/VuePlugin
docs(website): fix get started docs for new Vue Plugin
2 parents 9bb2d96 + 1236cf7 commit 9993d67

File tree

3 files changed

+110
-44
lines changed

3 files changed

+110
-44
lines changed

packages/overmind-website/examples/guide/getstarted/connectapp.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ export default connect(Posts)
2525
],
2626
vue: [
2727
{
28-
fileName: 'Posts.vue (template)',
29-
target: 'markup',
28+
fileName: 'index.js',
3029
code: `
31-
<h4 v-if="state.isLoadingPosts">
32-
Loading posts...
33-
</h4>
34-
<div v-else></div>
35-
`,
30+
import Vue from 'vue'
31+
import { OvermindPlugin } from './overmind'
32+
import Posts from './components/Posts'
33+
34+
Vue.use(OvermindPlugin)
35+
36+
new Vue({
37+
el: '#app',
38+
render: (h) => h(App),
39+
})
40+
41+
`,
3642
},
3743
],
3844
}
Lines changed: 89 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
import { tsAppIndex } from '../../templates'
22

3-
export default (ts, view) =>
4-
ts
5-
? [
6-
{
7-
fileName: 'overmind/state.ts',
8-
code: `
3+
const javascript = {
4+
react: [
5+
{
6+
fileName: 'overmind/index.js',
7+
code: `
8+
import { Overmind } from 'overmind'
9+
import { createConnect } from 'overmind-react'
10+
11+
export const overmind = new Overmind({
12+
state: {
13+
isLoadingPosts: false
14+
}
15+
})
16+
17+
export const connect = createConnect(overmind)
18+
`,
19+
},
20+
],
21+
vue: [
22+
{
23+
fileName: 'overmind/index.js',
24+
code: `
25+
import { Overmind } from 'overmind'
26+
import { createPlugin } from 'overmind-vue'
27+
28+
export const overmind = new Overmind({
29+
state: {
30+
isLoadingPosts: false
31+
}
32+
})
33+
34+
export const OvermindPlugin = createPlugin(overmind)
35+
`,
36+
},
37+
],
38+
}
39+
40+
const typescript = {
41+
react: [
42+
{
43+
fileName: 'overmind/state.ts',
44+
code: `
945
export type Post = {
1046
id: number
1147
title: string
@@ -21,36 +57,58 @@ export const state: State = {
2157
isLoadingPosts: false,
2258
posts: []
2359
}
24-
`,
25-
},
26-
{
27-
fileName: 'overmind/index.ts',
28-
code: tsAppIndex(
29-
view,
30-
`
60+
`,
61+
},
62+
{
63+
fileName: 'overmind/index.ts',
64+
code: tsAppIndex(
65+
'react',
66+
`
3167
import { state } from './state'
3268
3369
const config = {
3470
state,
3571
}
3672
`
37-
),
38-
},
39-
]
40-
: [
41-
{
42-
fileName: 'overmind/index.js',
43-
code: `
44-
import { Overmind } from 'overmind'
45-
import { createConnect } from 'overmind-${view}'
73+
),
74+
},
75+
],
76+
vue: javascript.vue,
77+
angular: [
78+
{
79+
fileName: 'overmind/state.ts',
80+
code: `
81+
export type Post = {
82+
id: number
83+
title: string
84+
body: string
85+
}
4686
47-
export const overmind = new Overmind({
48-
state: {
49-
isLoadingPosts: false
50-
}
51-
})
87+
export type State = {
88+
isLoadingPosts: boolean
89+
posts: Post[]
90+
}
5291
53-
export const connect = createConnect(overmind)
54-
`,
55-
},
56-
]
92+
export const state: State = {
93+
isLoadingPosts: false,
94+
posts: []
95+
}
96+
`,
97+
},
98+
{
99+
fileName: 'overmind/index.ts',
100+
code: tsAppIndex(
101+
'angular',
102+
`
103+
import { state } from './state'
104+
105+
const config = {
106+
state,
107+
}
108+
`
109+
),
110+
},
111+
],
112+
}
113+
114+
export default (ts, view) => (ts ? typescript[view] : javascript[view])

packages/overmind-website/guides/beginner/01_getstarted.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ If you are moving from an existing state management solution, please read the re
44

55
To get started with Overmind you have to set up a project. You can do this with whatever tool your framework of choice provides or you can use [webpack](https://webpack.js.org/) or [parceljs](https://parceljs.org/). You can also use [codesandbox.io](https://codesandbox.io/) to play around with Overmind directly in the browser.
66

7-
```marksy
8-
h(TypescriptNotice, null, "Overmind requires Typescript version **3.2** or above")
9-
```
10-
117
```marksy
128
h(Notice, null, "Due to using the Proxy feature of JavaScript, Overmind does not support **Internet Explorer 11**.")
139
```
@@ -19,6 +15,12 @@ When you have your project up and running install the Overmind dependency by usi
1915
h(Example, { name: "guide/getstarted/install" })
2016
```
2117

18+
```marksy
19+
h(TypescriptNotice, null, "Overmind requires Typescript version **3.2** or above")
20+
```
21+
22+
23+
2224
Great, we are good to go!
2325

2426
## Our first state
@@ -31,7 +33,7 @@ Let us imagine we get what we need from Overmind in a component:
3133
h(Example, { name: "guide/getstarted/loadingposts" })
3234
```
3335

34-
This will of course not work. To make this work we have to create an Overmind application instance.
36+
This will of course not work. To make this work we have to create an Overmind application instance and expose it to our component.
3537

3638
```marksy
3739
h(Example, { name: "guide/getstarted/createapp" })
@@ -43,7 +45,7 @@ Now that we have our application, let us expose it to our component.
4345
h(Example, { name: "guide/getstarted/connectapp" })
4446
```
4547

46-
That is it, your component will now render whenever the state accessed changes.
48+
That is it, your component will now render whenever the state accessed changes. Please read more about connecting state to components in the [guides section](/guides).
4749

4850
## Effects
4951

0 commit comments

Comments
 (0)