You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/overmind-website/api/action.md
+25-9Lines changed: 25 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Action
2
2
3
3
```marksy
4
-
<Examplename="api/action" />
4
+
h(Example, { name: "api/action"})
5
5
```
6
6
7
7
An action allows you to compose pieces of logic into an execution. You typically execute an action based on some user interaction in your application, but it could be everything from a route change to a websocket message as well.
@@ -10,9 +10,16 @@ Actions are defined with a powerful chaining API which gives control of the exec
10
10
11
11
The action is built up by **operators**, methods called on the action itself. These operators describes the execution logic.
12
12
13
+
## compose
14
+
```marksy
15
+
h(Example, { name: "api/action_compose" })
16
+
```
17
+
18
+
Typically used to merge in a separate action. This action will runs as if it was defined with the source action.
19
+
13
20
## debounce
14
21
```marksy
15
-
<Examplename="api/action_debounce" />
22
+
h(Example, { name: "api/action_debounce" })
16
23
```
17
24
18
25
Typically used to only continue execution of the last action call if multiple action calls has been made in the time limit passed in.
@@ -21,7 +28,7 @@ The only argument is the time limit in milliseconds the operator should prevent
21
28
22
29
## do
23
30
```marksy
24
-
<Examplename="api/action_do" />
31
+
h(Example, { name: "api/action_do" })
25
32
```
26
33
27
34
Typically used to fire off an effect without caring about its returned result, if any.
@@ -30,7 +37,7 @@ Only argument is a function that receives the **effects** registered in the appl
30
37
31
38
## filter
32
39
```marksy
33
-
<Examplename="api/action_filter" />
40
+
h(Example, { name: "api/action_filter" })
34
41
```
35
42
36
43
Typically used to stop execution related to some condition.
@@ -39,7 +46,7 @@ The first argument is a function that receives the **effects** registered in the
39
46
40
47
## fork
41
48
```marksy
42
-
<Examplename="api/action_fork" />
49
+
h(Example, { name: "api/action_fork" })
43
50
```
44
51
Typically used to fork out execution when a value can result in multiple complex executions.
45
52
@@ -48,7 +55,7 @@ The first argument is a function that receives the **effects** as the first argu
48
55
49
56
## map
50
57
```marksy
51
-
<Examplename="api/action_map" />
58
+
h(Example, { name: "api/action_map" })
52
59
```
53
60
54
61
Typically used to get values from an effect or transform the current value of the action.
@@ -57,16 +64,25 @@ Only argument is a function that receives the **effects** registered in the appl
57
64
58
65
## mutate
59
66
```marksy
60
-
<Examplename="api/action_mutation" />
67
+
h(Example, { name: "api/action_mutation" })
61
68
```
62
69
63
70
Used to change the state of the application.
64
71
65
72
Only argument is a function that receives the **state** as the first argument and the current **value** of the action as the second argument. This operator is the only operator that is allowed to mutate the state of the application.
66
73
74
+
## parallel
75
+
```marksy
76
+
h(Example, { name: "api/action_parallel" })
77
+
```
78
+
79
+
Typically used to run multiple composed actions in parallel. "In parallel" means that one executes after the other synchronously, but if any of them are doing something asynchronous the execution of the source action will not continue until all of them are done.
80
+
81
+
The parallel operator does not return a value.
82
+
67
83
## try
68
84
```marksy
69
-
<Examplename="api/action_try" />
85
+
h(Example, { name: "api/action_try" })
70
86
```
71
87
72
88
Typically used to explicitly handle potentially thrown errors from an effect.
@@ -75,7 +91,7 @@ The first argument is a function that receives the **effects** registered in the
75
91
76
92
## when
77
93
```marksy
78
-
<Examplename="api/action_when" />
94
+
h(Example, { name: "api/action_when" })
79
95
```
80
96
81
97
Typically used to fork execution based on a thruthy or falsy value.
Copy file name to clipboardExpand all lines: packages/overmind-website/api/app.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,5 +3,5 @@
3
3
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.
Copy file name to clipboardExpand all lines: packages/overmind-website/api/compute.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Compute
2
2
3
3
```marksy
4
-
<Examplename="api/compute" view/>
4
+
h(Example, { name: "api/compute", view: true })
5
5
```
6
6
7
7
You can add computed state values. These state values are functions that takes one argument, `filterNameBy` in the example above. This argument can be whatever you want, but it can only be a single argument. That means if you want to pass in multiple values you would pass those as part of an object. The reason computed state values work like this is because this argument is the cache key. As long as you pass in the same argument and the accessed state is not changed, the cached value is instantly returned.
Copy file name to clipboardExpand all lines: packages/overmind-website/api/connect.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Connect
2
2
3
3
```marksy
4
-
<Examplename="api/connect" view/>
4
+
h(Example, { name: "api/connect", view: true })
5
5
```
6
6
7
7
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 the **connect** function and pass in the component.
You can add derived state to your application. You access derived state like any other value, there is not need to call it as a function. The derived value is cached and will only update when any accessed state changes.
There is really no API with effects. You just expose existing libraries or create your own APIs for doing side effects. When these effects are attached to the application they will be tracked by the devtools giving you additional debugging information. By "injecting" the effects this way also opens up for easier testability of your logic.
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.
0 commit comments