Skip to content

Commit 566c2ac

Browse files
christianalfonigitbook-bot
authored andcommitted
GitBook: [master] 2 pages modified
1 parent 5953feb commit 566c2ac

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

core/defining-state.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ export const state = {
113113
{% endtab %}
114114
{% endtabs %}
115115

116+
{% hint style="warning" %}
117+
It is import that you do **NOT** use arrow functions on your methods. The reason is that this binds the context of the method to the instance itself, meaning that Overmind is unable to proxy access and allow you to do tracked mutations
118+
{% endhint %}
119+
116120
You can now use this instance as normal and of course create new ones.
117121

118122
{% hint style="info" %}

core/typescript.md

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -387,41 +387,7 @@ export const filterAwesome: <T extends { isAwesome: boolean }>() => Operator<T>
387387

388388
That means this operator can handle any type that matches an **isAwesome** property, though will pass the original type through.
389389

390-
## Statemachine
391-
392-
Statemachines exposes a type called **Statemachine** which you will give a single type argument of what states it should manage:
393-
394-
{% tabs %}
395-
{% tab title="overmind/state.ts" %}
396-
```typescript
397-
import { Statemachine, statemachine } from 'overmind'
398-
399-
type Mode =
400-
| 'unauthenticated'
401-
| 'authenticating'
402-
| 'authenticated'
403-
| 'unauthenticating'
404-
405-
type State = {
406-
mode: Statemachine<Mode>
407-
}
408-
409-
export const state: State = {
410-
mode: statemachine<Mode>({
411-
initial: 'unauthenticated',
412-
states: {
413-
unauthenticated: ['authenticating'],
414-
authenticating: ['unauthenticated', 'authenticated'],
415-
authenticated: ['unauthenticating'],
416-
unauthenticating: ['unauthenticated', 'authenticated']
417-
}
418-
})
419-
}
420-
```
421-
{% endtab %}
422-
{% endtabs %}
423-
424-
## Statechart
390+
## Statecharts
425391

426392
To type a statechart you use the **Statechart** type:
427393

0 commit comments

Comments
 (0)