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
So essentially, `createAction` provided us with an easy way of creating a single action. `addCategory` in our case is an `ActionCreator`, a function which produces an action object whenever called, and `props` explained what argument that `ActionCreator` function expects.
@@ -67,7 +70,7 @@ So essentially, `createAction` provided us with an easy way of creating a single
67
70
68
71
As we just saw, creating an action is pretty straightforward.
69
72
70
-
However, when dealing with multiple actions, this can led to a more verbose code and prone to typos:
73
+
However, when dealing with multiple actions, this can lead to a more verbose code and prone to typos:
71
74
72
75
```ts title="state/actions.ts"
73
76
exportconst addCategory =createAction(
@@ -87,7 +90,7 @@ With those issues in mind, NgRx published a new function that allows us to creat
87
90
Its usage is fairly simple and is based on two parameters:
88
91
89
92
- The source of the action, in our case `Category List`
90
-
- A serie of properties symbolizing our actions and their parameters
93
+
- A series of properties symbolizing our actions and their parameters
91
94
92
95
Let's go back to the previous example to see what is changing:
Notice that our action types like `Add Category` written in plain English are converted to `addCategory` - a camel case variable name. This magic is done using [TypeScript's template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html) and the [mapped types](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#handbook-content). [The source code for this](https://github.com/ngrx/platform/blob/master/modules/store/src/action_group_creator_models.ts) is pretty fascinating, if you're a TypeScript enthusiast, I strongly recommend checking it out or listen to. You can also listen to [Brandon Robert's video about the "TypeScript magic" behind the scenes](https://www.youtube.com/watch?v=V6eHIvwDFP4).
117
+
118
+
:::
119
+
111
120
## Homework
112
121
113
122
Yes, you've read it correctly: we have learned how to write some basic code in NgRx, so it is time for some homework!
@@ -118,16 +127,16 @@ We **strongly** recommand you not to move on to the next chapter without adding
118
127
119
128
:::
120
129
121
-
1.**Create an action for deleting a category**
130
+
1.**Create an action for deleting a category**
122
131
It should receive a string with the name of the category, and in the next chapter we will use that code to write the actual logic for deleting the category.
123
-
2.**Create an action for updating a category**
132
+
2.**Create an action for updating a category**
124
133
It must receive a `Category` object (`{name: string}`), and again, we will write the code to update the category in the next chapter
125
134
126
135
> For this homework, assume categories cannot have duplicate names. We will deal with this problem later.
127
136
128
137
:::note
129
138
130
-
You will find solution code for all the homeworks in the end of the chapters
139
+
You will find solution code for all the homeworks at the end of the chapters
0 commit comments