Created
April 11, 2018 02:57
-
-
Save agoldis/c8f9c914a35e58c563364acfa1611a15 to your computer and use it in GitHub Desktop.
redux blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const initialState = { | |
| users: [{ id: "user01", name: "John" }, { id: "user02", name: "Bob" }], | |
| tasks: [ | |
| { id: "task01", title: "Wash car", assignee: "user01" }, | |
| { id: "task02", title: "Watch tutorial", assignee: "user01" }, | |
| { id: "task03", title: "Do Homework", assignee: "user02" } | |
| ], | |
| get userTasks() { | |
| return this.users.map(user => | |
| Object.assign({}, user, { | |
| tasks: this.tasks.filter(task => task.assignee === user.id) | |
| }) | |
| ); | |
| }, | |
| get userTasksCount() { | |
| return this.userTasks.map(user => Object.assign({}, user, { tasksCount: user.tasks.count }) | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment