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: README.md
+31-19Lines changed: 31 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,9 +33,9 @@ Building your application with a single state tree is the most straight forward
33
33
Separate 3rd party APIs and logic not specific to your application by using **effects**. This will keep your application logic pure and without low level APIs cluttering your code.
When you build applications that perform many state changes things can get out of hand. In Overmind you can only perform state changes from **actions** and all changes are tracked by the development tool.
@@ -71,8 +71,8 @@ Even though Overmind can create applications with only plain **state** and **act
71
71
72
72
{% tabs %}
73
73
{% tab title="Operators" %}
74
-
```javascript
75
-
exportconstsearch=pipe(
74
+
```typescript
75
+
exportconst search:Operator<string>=pipe(
76
76
mutate(({ state }, query) => {
77
77
state.query=query
78
78
}),
@@ -88,8 +88,16 @@ export const search = pipe(
88
88
{% endtab %}
89
89
90
90
{% tab title="Statechart" %}
91
-
```javascript
92
-
constloginChart= {
91
+
```typescript
92
+
const loginChart:Statechart<
93
+
typeofconfig,
94
+
{
95
+
LOGIN:void
96
+
AUTHENTICATING:void
97
+
AUTHENTICATED:void
98
+
ERROR:void
99
+
}
100
+
> = {
93
101
initial: 'LOGIN',
94
102
states: {
95
103
LOGIN: {
@@ -121,15 +129,15 @@ const loginChart = {
121
129
{% endtab %}
122
130
123
131
{% tab title="Class state" %}
124
-
```javascript
132
+
```typescript
125
133
classLoginForm() {
126
-
private username =''
127
-
private password =''
128
-
private validationError =''
129
-
changeUsername(username) {
134
+
private username:string=''
135
+
private password:string=''
136
+
private validationError:string=''
137
+
changeUsername(username:string) {
130
138
this.username=username
131
139
}
132
-
changePassword(password) {
140
+
changePassword(password:string) {
133
141
if (!password.match([0-9]) {
134
142
this.validationError='You need some numbers in your password'
135
143
}
@@ -140,7 +148,11 @@ class LoginForm() {
140
148
}
141
149
}
142
150
143
-
exportconststate= {
151
+
typeState= {
152
+
loginForm: LoginForm
153
+
}
154
+
155
+
exportconststate: State= {
144
156
loginForm: newLoginForm()
145
157
}
146
158
```
@@ -151,7 +163,7 @@ export const state = {
151
163
152
164
Bring in your application configuration of state, effects and actions. Create mocks for any effects. Take a snapshot of mutations performed in an action to ensure all intermediate states are met.
0 commit comments