typescript RX-reselect3.ts
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript RX-reselect3.ts相关的知识,希望对你有一定的参考价值。
@Injectable()
class TodosQuery {
getVisibilityFilter$ = this.store.select(state => state.visibilityFilter);
getTodos$ = this.store.select(state => state.todos);
getKeyword$ = this.store.select(state => state.keyword);
getVisibleTodos$ = Observable.combineLatest(
getVisibilityFilter$, getTodos$, this.calcVisibleTodos
)
private calcVisibleTodos = (visibilityFilter, todos) => {
switch (visibilityFilter) {
case 'SHOW_ALL':
return todos
case 'SHOW_COMPLETED':
return todos.filter(t => t.completed)
case 'SHOW_ACTIVE':
return todos.filter(t => !t.completed)
}
}
getVisibleTodosFilteredByKeyword$ = Observable.combineLatest(
getVisibleTodos$, getKeyword$,
(visibleTodos, keyword) => visibleTodos.filter(
todo => todo.text.includes(keyword)
)
)
constructor(private store: Store<AppState>) {}
}
以上是关于typescript RX-reselect3.ts的主要内容,如果未能解决你的问题,请参考以下文章
typescript RX-reselect2.ts
TypeScript入门学习之路
typescript TypeScript Snippets #typescript
TypeScript入门五:TypeScript的接口
TypeScript系列教程--初探TypeScript
TypeScript入门三:TypeScript函数类型