Skip to content

Commit

Permalink
Update chapter-5.mdx (#15)
Browse files Browse the repository at this point in the history
A minor typo - fixed
  • Loading branch information
kishoreandra authored Sep 29, 2024
1 parent 981f240 commit 1e367dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/chapter-5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const addCategory = createAction(
);
```

Let's break down this example. First of all, the name `createAction` is a bit deceptive; it does not create an action; in fact, it creates a function which, when called, wil produce an action object. The first argument is the `type` of the action that will be produced. When called, the `addCategory` function will **always** create an action with type "[Category List] Create Category". The second argument uses the bizarre function `props`, which is a generic function that allows us to define the type of the `payload` which the created action will have. Essentially, it explains that in order to create the action using the `addCategory` function, we should call it and provide an object that has a property `category` which is defined in the Interface Category defined in the AppState. Let's do this and `console.log` the result.
Let's break down this example. First of all, the name `createAction` is a bit deceptive; it does not create an action; in fact, it creates a function which, when called, will produce an action object. The first argument is the `type` of the action that will be produced. When called, the `addCategory` function will **always** create an action with type "[Category List] Create Category". The second argument uses the bizarre function `props`, which is a generic function that allows us to define the type of the `payload` which the created action will have. Essentially, it explains that in order to create the action using the `addCategory` function, we should call it and provide an object that has a property `category` which is defined in the Interface Category defined in the AppState. Let's do this and `console.log` the result.

```ts title="app.component.ts"
import { Component, OnInit } from "@angular/core";
Expand Down

0 comments on commit 1e367dd

Please sign in to comment.