Skip to content

Commit c2eb6de

Browse files
docs(overmind): add api for statecharts and fix api section
1 parent 83d97e2 commit c2eb6de

33 files changed

+654
-182
lines changed

packages/overmind-website/api/action.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Action
1+
# action
22

33
```marksy
44
h(Example, { name: "api/action"})
@@ -12,7 +12,7 @@ This *injected* context allows Overmind to understand from where you are changin
1212

1313
State changes are restricted to these actions. That means if you try to change the state outside of an action you will get an error. The state changes are also scoped to the action. That means it does not matter if you perform the state change asynchronously, either by defining the action as an **async** function or for example use a **setTimeout**. You can change the state at any time within the action.
1414

15-
## Payload
15+
## payload
1616

1717
When an action is called you can optionally pass it a payload. This payload is received as the second argument to the action.
1818

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# addFlushListener
2+
3+
The **addMutationListener** triggers whenever there is a mutation. The **addFlushListener** triggers whenever Overmind tells components to render again. It can have multiple mutations related to it.
4+
5+
```marksy
6+
h(Example, { name: "api/app_addFlushListener" })
7+
```
8+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# addMutationListener
2+
3+
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. Note that this method triggers before the mutation occurs, you might rather want to use **addFlushListener** to be notified about batched changes, like the components does.
4+
5+
```marksy
6+
h(Example, { name: "api/app_addMutationListener" })
7+
```

packages/overmind-website/api/config.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/overmind-website/api/overmind.md renamed to packages/overmind-website/api/createOvermind.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
# Overmind
1+
# createOvermind
22

33
The **createOvermind** factory is used to create the application instance. You need to create and export a mechanism to connect your instance to the components. Please look at the guides for each view layer for more information.
44

55
```marksy
66
h(Example, { name: "api/app_initialize" })
77
```
88

9-
You can pass a second argument to the **createOvermind** factory. This is an options object with the following properties:
10-
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. Note that this method triggers before the mutation occurs, you might rather want to use **addFlushListener** to be notified about batched changes, like the components does.
14-
15-
```marksy
16-
h(Example, { name: "api/app_addMutationListener" })
17-
```
18-
19-
## addFlushListener
20-
21-
The **addMutationListener** triggers whenever there is a mutation. The **addFlushListener** triggers whenever Overmind tells components to render again. It can have multiple mutations related to it.
22-
23-
```marksy
24-
h(Example, { name: "api/app_addFlushListener" })
25-
```
9+
You can pass a second argument to the **createOvermind** factory. This is an options object with the following properties.
2610

2711
## options.devtools
2812
If you develop your app on localhost the application connects to the devtools on **localhost:3031**. You can change this in case you need to use an IP address, the devtools is configured with a different port or you want to connect to localhost (with default port) even though the app is not on localhost.

packages/overmind-website/api/mock.md renamed to packages/overmind-website/api/createOvermindMock.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Mock
1+
# createOvermindMock
22

33
The **createOvermindMock** factory creates an instance of Overmind which can be used to test actions. You can mock out effects and evaluate mutations performed during action execution.
44

packages/overmind-website/api/derive.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Derive
1+
# derive
22

33
You can add derived state to your application. You access derived state like any other value, there is no need to call it as a function. The derived value is cached and will only update when any accessed state changes.
44

packages/overmind-website/api/effects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Effects
1+
# effects
22

33
```marksy
44
h(Example, { name: "api/effects" })

packages/overmind-website/api/json.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Json
1+
# json
22

33
Overmind wraps objects and arrays in your state structure with proxies. If you pass state to 3rd party libraries, to a service worker or similar, you should pass a long a copy of that state. This avoids the 3rd party tool from mutating your state when you do not want it to.
44

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# lazy
2+
3+
You can lazy load configurations. You do this by giving each configuration a key with a function that returns the config when called. To actually load the configurations you can either call an effect or an action with the key of the configuration to load.
4+
5+
```marksy
6+
h(Example, { name: "api/config_lazy" })
7+
```

0 commit comments

Comments
 (0)