Skip to content

Instantly share code, notes, and snippets.

@artberri
Created May 28, 2019 17:57
Show Gist options
  • Select an option

  • Save artberri/07210c080b3ad18375a90253c01a7184 to your computer and use it in GitHub Desktop.

Select an option

Save artberri/07210c080b3ad18375a90253c01a7184 to your computer and use it in GitHub Desktop.
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