zoukankan      html  css  js  c++  java
  • [Angular] Ngrx/effects, Action trigger another action

    @Injectable()
    export class LoadUserThreadsEffectService {
    
      constructor(private action$: Actions, private threadsService: ThreadsService) {
      }
    
      @Effect()
      userThreadsEffect$: Observable<Action> = this.action$
        .ofType(LOAD_USER_THREADS_ACTION)
        .switchMap((action) => this.threadsService.loadUserThreads(action.payload))
        .map((allUserData) => new LoadUserThreadsSuccess(allUserData));
    
      @Effect()
      userSelectedEffect$: Observable<Action> = this.action$
        .ofType(USER_SELECTED_ACTION)
        .map((action) => new LoadUserThreadsAction(action.payload))
    }

    For the first Effect, 

    LOAD_USER_THREADS_ACTION

    will trigger another action:

    .map((allUserData) => new LoadUserThreadsSuccess(allUserData));

    Second effect:

    .ofType(USER_SELECTED_ACTION)

    will trigger another action:

    .map((action) => new LoadUserThreadsAction(action.payload))
  • 相关阅读:
    centos安装python3
    MongoDB 索引
    dockerfile
    docker端口映射与容器互联
    操作docker容器
    docker数据管理
    ubuntu安装docker
    MVC框架
    图像标签
    HTML的标签
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6351640.html
Copyright © 2011-2022 走看看