Skip to content

Commit 3dc31ce

Browse files
Merge pull request cerebral#72 from cerebral/moreDocs4
refactor(website): refactor example code, add github link and change …
2 parents ef3898f + 930caa6 commit 3dc31ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1890
-1870
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"vue": "2.5.16",
4545
"vue-hot-reload-api": "2.3.0",
4646
"vue-styled-components": "1.3.0",
47-
"ws": "5.2.1"
47+
"ws": "5.2.1",
48+
"preact": "8.3.1",
49+
"preact-compat": "3.18.4"
4850
},
4951
"devDependencies": {
5052
"@babel/core": "7.0.0",

packages/overmind-website/api/app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
The **App** class is used to create the application instance. The instance itself exposes a **connect** function used to connect views to the state of the application and allow them to trigger actions. Following is a simple example to show you the structure.
44

55
```marksy
6-
h(Example, { name: "api/app_initialize", view: true })
6+
h(Example, { name: "api/app_initialize" })
77
```

packages/overmind-website/api/connect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Connect
22

33
```marksy
4-
h(Example, { name: "api/connect", view: true })
4+
h(Example, { name: "api/connect" })
55
```
66

77
When you instantiate an Overmind application it exposes the ability to connect components to the state and actions defined. This is simply done by using **connect**.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Modules
22

33
```marksy
4-
h(Example, { name: "api/modules", view: true })
4+
h(Example, { name: "api/modules" })
55
```
66

77
When you have multiple application configurations, each with their own state, effects etc. you can give them a namespace by simply importing the modules and attach them to the **modules** config property.

packages/overmind-website/api/onInitialize.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
If you need to run logic as the application initializes you can use the **onInitialize** hook. This is defined as an action.
44

55
```marksy
6-
h(Example, { name: "api/onInitialize", view: true })
6+
h(Example, { name: "api/onInitialize" })
77
```
88

99
Overmind will first run any module defined onInitialize in parallel. After that the main onInitialize runs. You can see this in the devtools as well. The reason it works this way is because you module defined onInitialize indicates that you want to prepare something related to that module specifically, you do not care about the rest. The root onInitialize covers all the modules and allows you to orchestrate logic when those are indeed ready.

packages/overmind-website/api/reaction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can register reactions to act whenever a state path is affected by a mutatio
99
## Component
1010

1111
```marksy
12-
h(Example, { name: "api/reaction_component", view: true })
12+
h(Example, { name: "api/reaction_component" })
1313
```
1414

1515
Inside components reactions can be registered to perform view related side effects. These reactions are unregistered automatically when the component unmounts.
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
export const js = [
2-
{
3-
code: `
4-
export const doThis = action =>
1+
export default (ts) =>
2+
ts
3+
? [
4+
{
5+
code: `
6+
import { Action } from 'overmind'
7+
8+
export const doThis: Action<number> = action =>
59
action()
610
.map(operations.getUser)
711
.mutate(mutations.setUser)
812
`,
9-
},
10-
]
11-
12-
export const ts = [
13-
{
14-
code: `
15-
import { Action } from 'overmind'
16-
17-
export const doThis: Action<number> = action =>
13+
},
14+
]
15+
: [
16+
{
17+
code: `
18+
export const doThis = action =>
1819
action()
1920
.map(operations.getUser)
2021
.mutate(mutations.setUser)
2122
`,
22-
},
23-
]
23+
},
24+
]
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
export const js = [
2-
{
3-
fileName: 'app/actions.js',
4-
code: `
1+
export default (ts) =>
2+
ts
3+
? [
4+
{
5+
fileName: 'app/actions.ts',
6+
code: `
57
import * as operations from './operations'
68
7-
export const goDoSomethingWithString = action =>
9+
export const goDoSomethingWithString: Action<string> = action =>
810
action()
911
10-
export const doThis = action =>
12+
export const doThis: Action<string> = action =>
1113
action()
1214
.map(operations.transformString)
1315
.compose(goDoSomethingWithString)
1416
`,
15-
},
16-
]
17-
18-
export const ts = [
19-
{
20-
fileName: 'app/actions.ts',
21-
code: `
17+
},
18+
]
19+
: [
20+
{
21+
fileName: 'app/actions.js',
22+
code: `
2223
import * as operations from './operations'
2324
24-
export const goDoSomethingWithString: Action<string> = action =>
25+
export const goDoSomethingWithString = action =>
2526
action()
2627
27-
export const doThis: Action<string> = action =>
28+
export const doThis = action =>
2829
action()
2930
.map(operations.transformString)
3031
.compose(goDoSomethingWithString)
3132
`,
32-
},
33-
]
33+
},
34+
]
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
export const js = [
2-
{
3-
code: `
4-
export const doThis = action =>
5-
action()
6-
.debounce(200)
7-
`,
8-
},
9-
]
10-
11-
export const ts = [
12-
{
13-
code: `
1+
export default (ts) =>
2+
ts
3+
? [
4+
{
5+
code: `
146
import { Action } from 'overmind'
157
168
export const doThis: Action = action =>
179
action()
1810
.debounce(200)
1911
`,
20-
},
21-
]
12+
},
13+
]
14+
: [
15+
{
16+
code: `
17+
export const doThis = action =>
18+
action()
19+
.debounce(200)
20+
`,
21+
},
22+
]
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1-
export const js = [
2-
{
3-
fileName: 'app/operations.js',
4-
code: `
5-
export const trackSubmitForm = ({ track }) =>
6-
track.interaction('submitForm')
7-
`,
8-
},
9-
{
10-
fileName: 'app/actions.js',
11-
code: `
12-
export const doThis = action =>
13-
action()
14-
.do(operations.trackSubmitForm)
15-
`,
16-
},
17-
]
18-
19-
export const ts = [
20-
{
21-
fileName: 'app/operations.ts',
22-
code: `
1+
export default (ts) =>
2+
ts
3+
? [
4+
{
5+
fileName: 'app/operations.ts',
6+
code: `
237
import { Operation } from 'overmind'
248
259
export const trackSubmitForm: Operation.Do = ({ track }) =>
2610
track.interaction('submitForm')
2711
`,
28-
},
29-
{
30-
fileName: 'app/actions.ts',
31-
code: `
12+
},
13+
{
14+
fileName: 'app/actions.ts',
15+
code: `
3216
import { Action } from 'overmind'
3317
3418
export const doThis: Action = action =>
3519
action()
3620
.do(operations.trackSubmitForm)
3721
`,
38-
},
39-
]
22+
},
23+
]
24+
: [
25+
{
26+
fileName: 'app/operations.js',
27+
code: `
28+
export const trackSubmitForm = ({ track }) =>
29+
track.interaction('submitForm')
30+
`,
31+
},
32+
{
33+
fileName: 'app/actions.js',
34+
code: `
35+
export const doThis = action =>
36+
action()
37+
.do(operations.trackSubmitForm)
38+
`,
39+
},
40+
]

0 commit comments

Comments
 (0)