Skip to content

Commit 31b84d1

Browse files
christianalfonigitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent 4355c31 commit 31b84d1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

introduction.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If you rather want to go right ahead and set up a local project, please have a l
88

99
Before we move on, have a quick look at this sandbox. It is a simple counter application and it gives you some foundation before talking more about Overmind and building applications.
1010

11-
{% embed url="https://codesandbox.io/s/overmind-counter-c4tuh?from-embed" %}
11+
{% embed url="https://codesandbox.io/s/overmind-counter-c4tuh?fontsize=14&hidenavigation=1&theme=dark&view=editor&runonclick=1" %}
1212

1313
## Application state VS Component state
1414

@@ -93,7 +93,7 @@ And as we will see later you will also be using **effects** from the context.
9393

9494
Now we will move to a more complex example. Please have a look:
9595

96-
{% embed url="https://codesandbox.io/s/overmind-todomvc-simple-097zs?from-embed" %}
96+
{% embed url="https://codesandbox.io/s/overmind-todomvc-simple-097zs?fontsize=14&hidenavigation=1&theme=dark&view=editor&runonclick=1" %}
9797

9898
We have now separated out the Overmind related logic into its own file, **app.js**. This file creates the Overmind instance and also exports how the components will interact with the state and the actions, the hook called **useApp**. Vue and Angular has other mechanisms conventional to those frameworks where application state and actions can be accessed.
9999

@@ -183,7 +183,7 @@ Any function you insert into the state tree is treated as derived state. That me
183183

184184
Now let us move into an even more complex application. Here we have added **effects**. Specifically effects to handle routing, storing todos to local storage and producing unique ids for the todos. We have added an **onInitialize** hook which is a special function Overmind runs when the application starts.
185185

186-
{% embed url="https://codesandbox.io/s/overmind-todomvc-2im6p?from-embed" %}
186+
{% embed url="https://codesandbox.io/s/overmind-todomvc-2im6p?fontsize=14&hidenavigation=1&theme=dark&view=editor&runonclick=1" %}
187187

188188
You can think of effects as a contract between your application and the outside world. You write an effect API of **what** your application needs and some 3rd party tool or native JavaScript API will implement **how** to provide it. Let us look at the router:
189189

@@ -223,7 +223,7 @@ This argument passed is transformed into something Page can understand. What thi
223223

224224
Defining all the state, actions and effects on one object would not work very well for a large application. A convention in Overmind is to split these concepts into different files behind folders representing a domain of the application. In this next sandbox you can see how we split up state, actions and effects into different files. They are all exposed through a main file representing that domain, in this case “the root domain”:
225225

226-
{% embed url="https://codesandbox.io/s/overmind-todomvc-split-xdh41?from-embed" %}
226+
{% embed url="https://codesandbox.io/s/overmind-todomvc-split-xdh41?fontsize=14&hidenavigation=1&theme=dark&view=editor&runonclick=1" %}
227227

228228
Also notice that we have split up the instantiation of Overmind from the definition of the application. What this allows us to do is reuse the same application configuration for testing purposes and/or server side rendering. We separate the definition from the instantiation.
229229

@@ -239,7 +239,7 @@ Have a look at this new project where we have typed the application:
239239
You have to **OPEN IN EDITOR** to get the full Typescript experience.
240240
{% endhint %}
241241

242-
{% embed url="https://codesandbox.io/s/overmind-todomvc-typescript-39h7y?from-embed" %}
242+
{% embed url="https://codesandbox.io/s/overmind-todomvc-typescript-39h7y?fontsize=14&hidenavigation=1&theme=dark&view=editor&runonclick=1" %}
243243

244244
As you can see we only have to add an **Action** type to our functions and optionally give it an input type. This is enough for the action to give you all information about the application. Try changing some code and even add some code to see how Typescript helps you to explore the application and ensure that you implement new functionality correctly.
245245

0 commit comments

Comments
 (0)