Created
May 28, 2019 17:57
-
-
Save artberri/07210c080b3ad18375a90253c01a7184 to your computer and use it in GitHub Desktop.
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
| export class GetVisibleTodosQueryHandler extends SimpleQueryHandler<Todo[]> { | |
| constructor( | |
| private readonly filterState: FilterState, | |
| private readonly todosState: TodosState | |
| ) { | |
| super(GetVisibleTodosQuery); | |
| } | |
| public handle(): Todo[] { | |
| switch (this.filterState.state) { | |
| case 'active': | |
| return this.todosState.state.filter(t => !t.isCompleted); | |
| case 'completed': | |
| return this.todosState.state.filter(t => t.isCompleted); | |
| default: | |
| return this.todosState.state; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment