Skip to content

Commit 5953feb

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

File tree

2 files changed

+67
-12
lines changed

2 files changed

+67
-12
lines changed

core/typescript.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,41 @@ 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-
## Statecharts
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
391425

392426
To type a statechart you use the **Statechart** type:
393427

quickstart.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const state = {
3535
```
3636
{% endtab %}
3737

38-
{% tab title="overmind/index.js" %}
38+
{% tab title="overmind/index.ts" %}
3939
```typescript
4040
import { state } from './state'
4141

@@ -44,20 +44,41 @@ export const config = {
4444
}
4545
```
4646
{% endtab %}
47+
{% endtabs %}
4748

48-
{% tab title="index.js" %}
49-
```typescript
50-
import { createOvermind } from 'overmind'
51-
import { config } from './overmind'
49+
And fire up your application in the browser or whatever environment your user interface is to be consumed in by the users.
50+
51+
### VS Code
52+
53+
For the best experience you should install the [OVERMIND DEVTOOLS](https://marketplace.visualstudio.com/items?itemName=christianalfoni.overmind-devtools-vscode) extension. This will allow you to work on your application without leaving the IDE at all.
54+
55+
![](.gitbook/assets/amazing_devtools.png)
56+
57+
{% hint style="info" %}
58+
If you are using the **Insiders** version of VSCode the extension will not work. It seems to be some extra security setting.
59+
{% endhint %}
60+
61+
### Devtool app
5262

53-
const overmind = createOvermind(config)
63+
Alternatively you can install the standalone application of the devtools. It is highly recommended to install the package [CONCURRENTLY](https://www.npmjs.com/package/concurrently). It allows you to start the devtools as you start your build process:
64+
65+
```text
66+
npm install overmind-devtools concurrently
5467
```
55-
{% endtab %}
56-
{% endtabs %}
5768

58-
And fire up your application in the browser or whatever environment your user interface is to be consumed in by the users.
69+
{% code title="package.json" %}
70+
```javascript
71+
{
72+
...
73+
"scripts": {
74+
"start": "concurrently \"overmind-devtools\" \"someBuildTool\""
75+
},
76+
...
77+
}
78+
```
79+
{% endcode %}
5980

60-
Move on with the specific view layer of choice to connect your app:
81+
### Hot Module Replacement <a id="quickstart-hot-module-replacement"></a>
6182

62-
\*\*\*\*[**REACT** ](views/react.md)**-** [**ANGULAR**](views/angular.md) **-** [**VUE**](views/vue.md)\*\*\*\*
83+
A popular concept introduced by Webpack is [HMR](https://webpack.js.org/concepts/hot-module-replacement/). It allows you to make changes to your code without having to refresh. Overmind automatically supports HMR. That means when **HMR** is activated Overmind will make sure it updates and manages its state, actions and effects. Even the devtools will be updated as you make changes.
6384

0 commit comments

Comments
 (0)