Skip to content

Commit fbc1678

Browse files
christianalfonigitbook-bot
authored andcommitted
GitBook: [master] 13 pages and 2 assets modified
1 parent 2c71343 commit fbc1678

File tree

14 files changed

+37
-49
lines changed

14 files changed

+37
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: frictionless state management
66

77
> Web application development is about **defining**, **changing** and **consuming state** to produce a user experience. Overmind aims for a developer experience where that is all you focus on, reducing the orchestration of state management to a minimum. Making you a **happier** and more **productive** developer!
88
9-
{% embed url="https://overmindjs.changefeed.app/general/v26" %}
9+
{% embed url="https://overmindjs.changefeed.app/general/v26" caption="" %}
1010

1111
## APPLICATION INSIGHT
1212

addons/graphql.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const config = {
3131

3232
{% tab title="overmind/state.js" %}
3333
```typescript
34-
3534
export const state = {
3635
posts: []
3736
}
@@ -183,7 +182,7 @@ export const getPosts = async ({ state, effects, actions }) => {
183182
const { posts } = await effects.gql.queries.posts()
184183

185184
state.posts = posts
186-
185+
187186
effects.gql.subscriptions.onPostAdded(actions.onPostAdded)
188187
}
189188

api-1/statemachine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const state = statemachine({
1818
})
1919
```
2020

21-
Instead of only defining state, you first define a set of transitions. The key represents a transition state, here **UNAUTHENTICATED**, **AUTHENTICATING** and **AUTHENTICATED**. Then we define an array which shows the next transition state can occur in the given transition state. When **UNAUTHENTICATED** we can move into the **AUTHENTICATING** state for example. When in **AUTHENTICATING** state we can move either back to **UNAUTHENTICATED** due to an error or we might move to **AUTHENTICATED**. The point is... when you are **UNAUTHENTICATED**, you can not run logic related to being **AUTHENTICATED**. And when **AUTHENTICATING** you can not run that logic again until you are back in **UNAUTHENTICATED**.
21+
Instead of only defining state, you first define a set of transitions. The key represents a transition state, here **UNAUTHENTICATED**, **AUTHENTICATING** and **AUTHENTICATED**. Then we define an array which shows the next transition state can occur in the given transition state. When **UNAUTHENTICATED** we can move into the **AUTHENTICATING** state for example. When in **AUTHENTICATING** state we can move either back to **UNAUTHENTICATED** due to an error or we might move to **AUTHENTICATED**. The point is... when you are **UNAUTHENTICATED**, you can not run logic related to being **AUTHENTICATED**. And when **AUTHENTICATING** you can not run that logic again until you are back in **UNAUTHENTICATED**.
2222

2323
As actual state values we define the initial transition state of **UNAUTHENTICATED**.
2424

core/defining-state.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ The **SERIALIZE** symbol will not be part of the actual serialization done with
197197

198198
#### Rehydrating classes
199199

200-
The [**rehydrate**](../api-1/rehydrate.md) _\*\*_utility of Overmind allows you to rehydrate state either by a list of mutations or a state object, like the following:
200+
The [**rehydrate**](../api-1/rehydrate.md) \_\*\*\_utility of Overmind allows you to rehydrate state either by a list of mutations or a state object, like the following:
201201

202202
{% tabs %}
203203
{% tab title="overmind/actions.js" %}
@@ -321,7 +321,7 @@ const state = {
321321

322322
You can not be authenticating and be authenticated at the same time. This kind of logic very often causes bugs in applications. That is why Overmind allows you to define statemachines. It sounds complicated, but is actually very simple.
323323

324-
To properly understand state machines, please read the guide [**Using state machines**](../guides-1/using-state-machines.md).
324+
To properly understand state machines, please read the guide [**Using state machines**](../guides-1/using-state-machines.md).
325325

326326
## References
327327

core/devtools.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ If you are using the **Insiders** version of VSCode the extension will not work.
5151
When you create your application it will automatically connect through **localhost:3031**, meaning that everything should just work out of the box. If you need to change the port, connect the application over a network \(mobile development\) or similar, you can configure how the application connects:
5252

5353
```javascript
54-
import { createOvermind } from 'overmind'
54+
import { createOvermind } from 'overmind'
5555
import { config } from './overmind'
5656

5757
const overmind = createOvermind(config, {
@@ -63,7 +63,7 @@ const overmind = createOvermind(config, {
6363

6464
ChromeOS does not expose localhost as normal. That means you need to connect with **penguin.termina.linux.test:3031**, or you can use the following plugin to forward **localhost:**
6565

66-
{% embed url="https://chrome.google.com/webstore/detail/connection-forwarder/ahaijnonphgkgnkbklchdhclailflinn/related?hl=en-US" %}
66+
{% embed url="https://chrome.google.com/webstore/detail/connection-forwarder/ahaijnonphgkgnkbklchdhclailflinn/related?hl=en-US" caption="" %}
6767

6868
## Hot Module Replacement
6969

@@ -104,8 +104,6 @@ import { Provider } from 'overmind-react'
104104
import { App } from './components/App'
105105

106106
render(<Provider value={overmind}><App /></Provider>, document.querySelector('#app'))
107-
108-
109107
```
110108
{% endtab %}
111109

core/server-side-rendering.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ export default class MyApp extends App {
204204
);
205205
}
206206
}
207-
208207
```
209208
{% endtab %}
210209
{% endtabs %}
@@ -226,7 +225,6 @@ export const config = {
226225
};
227226

228227
export const useOvermind = createHook();
229-
230228
```
231229

232230
And you are all set to get going with `overmind` and `next.js`. You can also take a look at [this example in the next.js examples directory](https://github.com/vercel/next.js/tree/canary/examples/with-overmind) if you need some help.
@@ -244,13 +242,12 @@ import { Provider } from "overmind-react"
244242
import { config } from "./src/overmind"
245243

246244
const overmind = createOvermind(config);
247-
245+
248246
export const wrapPageElement = ({ element }) => (
249247
<Provider value={createOvermind(config)}>
250248
{element}
251249
</Provider>
252250
)
253-
254251
```
255252

256253
After this is done we can do the same thing for the server render and add that code in the `gatsby-ssr.js` file:
@@ -270,7 +267,6 @@ export const wrapPageElement = ({ element }) => (
270267
{element}
271268
</Provider>
272269
)
273-
274270
```
275271

276272
As you can see the only difference we have here is that we createOvermindSSR in the `gatsby-ssr.js`

core/typescript.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const state: State = {
112112
{% endtabs %}
113113

114114
{% hint style="info" %}
115-
It is important that you use a **type** and not an **interface.** This has to do with the way Overmind resolves the state typing. ****
115+
It is important that you use a **type** and not an **interface.** This has to do with the way Overmind resolves the state typing. _\*\*_
116116
{% endhint %}
117117

118118
When writing Typescript you should **not** use optional values for your state \(**?**\), or use **undefined** in a union type. In a serializable state store world **null** is the value indicating _“there is no value”._
@@ -142,7 +142,7 @@ export const state: State = {
142142
{% tabs %}
143143
{% tab title="overmind/state.ts" %}
144144
```typescript
145-
import { derived } from 'overmind'
145+
import { derived } from 'overmind'
146146

147147
type State = {
148148
foo: string
@@ -162,7 +162,7 @@ Note that the type argument you pass is the object the derived is attached to, s
162162
{% tabs %}
163163
{% tab title="overmind/state.ts" %}
164164
```typescript
165-
import { derived } from 'overmind'
165+
import { derived } from 'overmind'
166166

167167
type State = {
168168
foo: string
@@ -245,7 +245,7 @@ There are no Overmind specific types related to effects, you just type them in g
245245
export const api = {
246246
getUser: async (): Promise<User> => {
247247
const response = await fetch('/user')
248-
248+
249249
return response.json()
250250
}
251251
}

faq.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ Restart VS Code
1414

1515
Operators are identified with a Symbol. If you happen to use Overmind across packages you might be running two versions of Overmind. The same goes for core package and view package installed out of version sync. Make sure you are only running on package of Overmind by looking into your **node\_modules** folder.
1616

17-
18-

guides-1/using-state-machines.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ By explicitly instantiating the machine you are allowed to start it in different
119119

120120
## Sending events
121121

122-
Instead of explicitly changing the state, you send an **event**. The events is handled by the state machine and it will ensure that it is valid before moving on. That means when you change from **AUTHENTICATING** to **AUTHENTICATED** you would express it something like:
122+
Instead of explicitly changing the state, you send an **event**. The events is handled by the state machine and it will ensure that it is valid before moving on. That means when you change from **AUTHENTICATING** to **AUTHENTICATED** you would express it something like:
123123

124124
```javascript
125125
export const authChanged = ({ state }, user) => {
@@ -131,7 +131,7 @@ export const authChanged = ({ state }, user) => {
131131
}
132132
```
133133

134-
When sending the **SIGNED\_IN** event we also provide the **user**. The current transition state of the machine is what decides if the user is set or not.
134+
When sending the **SIGNED\_IN** event we also provide the **user**. The current transition state of the machine is what decides if the user is set or not.
135135

136136
## Guarding effects
137137

@@ -163,7 +163,7 @@ type States =
163163
| {
164164
current: 'LIST'
165165
}
166-
166+
167167
type BaseState {
168168
list: Todo[]
169169
}
@@ -177,7 +177,7 @@ type Events =
177177
type: 'TODO_ADDED',
178178
data: Todo
179179
}
180-
180+
181181
export type TodosMachine = StateMachine<States, Events BaseState>
182182

183183
export const todos = statemachine<States, Events, BaseState>({
@@ -194,7 +194,7 @@ export const todos = statemachine<States, Events, BaseState>({
194194
})
195195
```
196196

197-
In this simple example we introduced a todos machine that starts in a **LOADING** state and will at some point transition into a **LIST** state when the initial todos has been loaded. The machine introduces the concept of **base state**. That means state that is available no matter what transition state the machine is in. The purpose of **base state** is that it simplifies typing and the machine will also automatically remove state related to the current transition state, when transitioning to a new state. In the example above the **user** and the **signedOutReason** is deleted when moving out of **AUTHENTICATED** state.
197+
In this simple example we introduced a todos machine that starts in a **LOADING** state and will at some point transition into a **LIST** state when the initial todos has been loaded. The machine introduces the concept of **base state**. That means state that is available no matter what transition state the machine is in. The purpose of **base state** is that it simplifies typing and the machine will also automatically remove state related to the current transition state, when transitioning to a new state. In the example above the **user** and the **signedOutReason** is deleted when moving out of **AUTHENTICATED** state.
198198

199199
## Nesting state machines
200200

@@ -266,15 +266,15 @@ All state machines has a **current** property. This can be used to evaluate what
266266
```javascript
267267
export const App = () => {
268268
const { state } = useOvermind()
269-
269+
270270
if (state.current === 'AUTHENTICATING') {
271271
return <div>Loading...</div>
272272
}
273-
273+
274274
if (state.current === 'AUTHENTICATED') {
275275
return <div>You are not authenticated</div>
276276
}
277-
277+
278278
return <div>Hello there!</div>
279279
}
280280
```
@@ -284,9 +284,9 @@ When dealing with nested machines you will have to do nested checks. This might
284284
```typescript
285285
export const Todos = () => {
286286
const { state } = useOvermind()
287-
287+
288288
if (!state.current === 'AUTHENTICATED') return null
289-
289+
290290
return (
291291
<div>
292292
{state.todos.current === 'LOADING' ? 'Loading...' : null}

0 commit comments

Comments
 (0)