ngrx - chain two store.select slices

后端 未结 3 1622
逝去的感伤
逝去的感伤 2021-02-13 21:00

In my Todo Cmp I have this code

this.todoListGroup$ = this.ngrx.select(fromRoot.getTodos)
    .flatMap((todos: Todo[]) => {
        console.log(todos)
                


        
3条回答
  •  青春惊慌失措
    2021-02-13 21:33

    This is an approach for RxJs v6+ using the combineLatest operator.

    First import the operators and Observable function like this:

    import { Observable, combineLatest } from 'rxjs';
    import { tap } from 'rxjs/operators';
    

    Then you can use them like this:

    combineLatest([
      this.store.pipe(select('users', 'userList')),
      this.store.pipe(select('users', 'accountsList')),
    ]).pipe(tap(([userList, accountsList]) => console.log(userList, accountsList)))
    

提交回复
热议问题