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
+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
@@ -6,7 +6,7 @@ description: frictionless state management
6
6
7
7
> 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!
Copy file name to clipboardExpand all lines: api-1/statemachine.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
@@ -18,7 +18,7 @@ export const state = statemachine({
18
18
})
19
19
```
20
20
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**.
22
22
23
23
As actual state values we define the initial transition state of **UNAUTHENTICATED**.
Copy file name to clipboardExpand all lines: core/defining-state.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,7 +197,7 @@ The **SERIALIZE** symbol will not be part of the actual serialization done with
197
197
198
198
#### Rehydrating classes
199
199
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:
201
201
202
202
{% tabs %}
203
203
{% tab title="overmind/actions.js" %}
@@ -321,7 +321,7 @@ const state = {
321
321
322
322
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.
323
323
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).
Copy file name to clipboardExpand all lines: core/devtools.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ If you are using the **Insiders** version of VSCode the extension will not work.
51
51
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:
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:**
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"
244
242
import { config } from"./src/overmind"
245
243
246
244
constovermind=createOvermind(config);
247
-
245
+
248
246
exportconstwrapPageElement= ({ element }) => (
249
247
<Provider value={createOvermind(config)}>
250
248
{element}
251
249
</Provider>
252
250
)
253
-
254
251
```
255
252
256
253
After this is done we can do the same thing for the server render and add that code in the `gatsby-ssr.js` file:
Copy file name to clipboardExpand all lines: core/typescript.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,7 +112,7 @@ export const state: State = {
112
112
{% endtabs %}
113
113
114
114
{% 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. _\*\*_
116
116
{% endhint %}
117
117
118
118
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 = {
142
142
{% tabs %}
143
143
{% tab title="overmind/state.ts" %}
144
144
```typescript
145
-
import {derived } from'overmind'
145
+
import {derived } from'overmind'
146
146
147
147
typeState= {
148
148
foo:string
@@ -162,7 +162,7 @@ Note that the type argument you pass is the object the derived is attached to, s
162
162
{% tabs %}
163
163
{% tab title="overmind/state.ts" %}
164
164
```typescript
165
-
import {derived } from'overmind'
165
+
import {derived } from'overmind'
166
166
167
167
typeState= {
168
168
foo:string
@@ -245,7 +245,7 @@ There are no Overmind specific types related to effects, you just type them in g
Copy file name to clipboardExpand all lines: faq.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,5 +14,3 @@ Restart VS Code
14
14
15
15
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.
Copy file name to clipboardExpand all lines: guides-1/using-state-machines.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,7 @@ By explicitly instantiating the machine you are allowed to start it in different
119
119
120
120
## Sending events
121
121
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:
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.
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.
198
198
199
199
## Nesting state machines
200
200
@@ -266,15 +266,15 @@ All state machines has a **current** property. This can be used to evaluate what
266
266
```javascript
267
267
exportconstApp= () => {
268
268
const { state } =useOvermind()
269
-
269
+
270
270
if (state.current==='AUTHENTICATING') {
271
271
return<div>Loading...</div>
272
272
}
273
-
273
+
274
274
if (state.current==='AUTHENTICATED') {
275
275
return<div>You are not authenticated</div>
276
276
}
277
-
277
+
278
278
return<div>Hello there!</div>
279
279
}
280
280
```
@@ -284,9 +284,9 @@ When dealing with nested machines you will have to do nested checks. This might
0 commit comments