Skip to content

Commit f66e3f4

Browse files
docs(website): remove reaction leftovers
1 parent e0de2db commit f66e3f4

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

packages/node_modules/overmind/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export type Configuration = {
1010
state?: {}
1111
effects?: {}
1212
actions?: {}
13-
reactions?: {}
1413
}
1514

1615
export type BaseApp = {

packages/overmind-website/api/overmind.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ h(Example, { name: "api/app_initialize" })
88

99
You can pass a second argument to the **App** constructor. This is an options object with the following properties:
1010

11-
## devtools
11+
## addMutationListener
12+
13+
It is possible to listen to all mutations performed in Overmind. This allows you to create special effects based on mutations within a certain domain of your app, or whatever else you come up with.
14+
15+
```marksy
16+
h(Example, { name: "api/app_addMutationListener" })
17+
```
18+
19+
20+
## options.devtools
1221
By default the application connects to the devtools on **localhost:3031**, but you can change this in case you need to use an IP address ot the devtools has configured with a different port.
1322

1423
```marksy
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { tsAppIndex } from '../templates'
2+
3+
export default (ts, view) =>
4+
ts
5+
? [
6+
{
7+
fileName: 'app/onInitialize.ts',
8+
code: `
9+
import { OnInitialize } from 'overmind'
10+
11+
const onInitialize: OnInitialize = async ({ value: overmind, state, localStorage }) => {
12+
overmind.addMutationListener((mutation) => {
13+
if (mutation.path.indexOf('todos') === 0) {
14+
localStorage.set('todos', state.todos)
15+
}
16+
})
17+
}
18+
19+
export default onInitialize
20+
`,
21+
},
22+
]
23+
: [
24+
{
25+
fileName: 'app/onInitialize.js',
26+
code: `
27+
const onInitialize = async ({ value: overmind, state, localStorage }) => {
28+
overmind.addMutationListener((mutation) => {
29+
if (mutation.path.indexOf('todos') === 0) {
30+
localStorage.set('todos', state.todos)
31+
}
32+
})
33+
}
34+
35+
export default onInitialize
36+
`,
37+
},
38+
]

0 commit comments

Comments
 (0)