当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Actions.ofType方法代码示例

本文整理汇总了TypeScript中@ngrx/effects.Actions.ofType方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Actions.ofType方法的具体用法?TypeScript Actions.ofType怎么用?TypeScript Actions.ofType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ngrx/effects.Actions的用法示例。


在下文中一共展示了Actions.ofType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: logout

 @Effect({ dispatch: false })
 logout(): Observable<Action> {
   return this.actions$.ofType(AuthActionTypes.LOGOUT).pipe(
     tap(action => {
       this.router.navigate(['']);
       this.localStorageService.setItem(AUTH_KEY, { isAuthenticated: false });
     })
   );
 }
开发者ID:gojay,项目名称:angular-ngrx-material-starter,代码行数:9,代码来源:auth.effects.ts

示例2: persistTodos

 @Effect({ dispatch: false })
 persistTodos(): Observable<Action> {
   return this.actions$
     .ofType(TodosActionTypes.PERSIST)
     .pipe(
       tap((action: ActionTodosPersist) =>
         this.localStorageService.setItem(TODOS_KEY, action.payload.todos)
       )
     );
 }
开发者ID:spairo,项目名称:angular-ngrx-material-starter,代码行数:10,代码来源:todos.effects.ts

示例3: persistThemeSettings

 @Effect({ dispatch: false })
 persistThemeSettings(): Observable<Action> {
   return this.actions$.ofType(SETTINGS_CHANGE_THEME).pipe(
     tap(action =>
       this.localStorageService.setItem(SETTINGS_KEY, {
         theme: action.payload
       })
     )
   );
 }
开发者ID:a727891,项目名称:bb,代码行数:10,代码来源:settings.effects.ts

示例4: login

 @Effect({ dispatch: false })
 login(): Observable<Action> {
   return this.actions$
     .ofType(AuthActionTypes.LOGIN)
     .pipe(
       tap(action =>
         this.localStorageService.setItem(AUTH_KEY, { isAuthenticated: true })
       )
     );
 }
开发者ID:spairo,项目名称:angular-ngrx-material-starter,代码行数:10,代码来源:auth.effects.ts

示例5: persistSettings

 @Effect({ dispatch: false })
 persistSettings(): Observable<Action> {
   return this.actions$.ofType(SettingsActionTypes.PERSIST).pipe(
     tap((action: ActionSettingsPersist) => {
       const { settings } = action.payload;
       const { pageAnimations, elementsAnimations } = settings;
       this.localStorageService.setItem(SETTINGS_KEY, settings);
       this.animationsService.updateRouteAnimationType(
         pageAnimations,
         elementsAnimations
       );
     })
   );
 }
开发者ID:gojay,项目名称:angular-ngrx-material-starter,代码行数:14,代码来源:settings.effects.ts

示例6: retrieveStock

 @Effect()
 retrieveStock(): Observable<Action> {
   return this.actions$.ofType(StockMarketActionTypes.RETRIEVE).pipe(
     tap((action: ActionStockMarketRetrieve) =>
       this.localStorageService.setItem(STOCK_MARKET_KEY, {
         symbol: action.payload.symbol
       })
     ),
     distinctUntilChanged(),
     debounceTime(500),
     switchMap((action: ActionStockMarketRetrieve) =>
       this.service
         .retrieveStock(action.payload.symbol)
         .pipe(
           map(stock => new ActionStockMarketRetrieveSuccess({ stock })),
           catchError(error =>
             of(new ActionStockMarketRetrieveError({ error }))
           )
         )
     )
   );
 }
开发者ID:gojay,项目名称:angular-ngrx-material-starter,代码行数:22,代码来源:stock-market.effects.ts

示例7: retrieveStock

 @Effect()
 retrieveStock(): Observable<Action> {
   return this.actions$.ofType(STOCK_MARKET_RETRIEVE).pipe(
     tap(action =>
       this.localStorageService.setItem(STOCK_MARKET_KEY, {
         symbol: action.payload
       })
     ),
     distinctUntilChanged(),
     debounceTime(500),
     switchMap(action =>
       this.service.retrieveStock(action.payload).pipe(
         map(stock => ({
           type: STOCK_MARKET_RETRIEVE_SUCCESS,
           payload: stock
         })),
         catchError(err =>
           of({ type: STOCK_MARKET_RETRIEVE_ERROR, payload: err })
         )
       )
     )
   );
 }
开发者ID:a727891,项目名称:bb,代码行数:23,代码来源:stock-market.effects.ts

示例8: constructor

    constructor(private actions: Actions) {

        this.stepStates = this.actions.ofType<ExecutorOutputAction>(ExecutorOutputAction.type).pipe(
            flatMap((action: ExecutorOutputAction) => {
                const {appID, message} = action;

                const composerMark = "Composer: ";
                const lines        = message.split("\n");

                const composerLogs = lines.reduce((acc, line) => {

                    const composerMarkIndex = line.indexOf(composerMark);
                    if (composerMarkIndex === -1) {
                        return acc;
                    }

                    const composerMessage = line.substr(composerMarkIndex + composerMark.length);

                    try {
                        const data = JSON.parse(composerMessage) as ComposerLogEntry;
                        return acc.concat({appID, data});
                    } catch (ex) {
                        console.warn("Could not parse composer message", composerMessage);
                        return acc;
                    }

                }, []);
                return of(...composerLogs);

            }),
            flatMap(action => {
                const {data} = action;
                const appID  = action.appID;
                if (data.hasOwnProperty("stepId")) {
                    const {status, stepId, message} = data as StepInfoLogEntry;

                    const stepParts        = stepId.split(".");
                    const firstLevelStepID = stepParts[1];
                    const isSubstep = stepParts.length > 2;

                    if (!firstLevelStepID) {
                        if (status === "FAILED") {
                            return of(new ExecutionErrorAction(appID, new ExecutionError(undefined, message, "execution")));
                        }
                        return empty();
                    }

                    switch (status) {
                        case "COMPLETED":
                            if (!isSubstep) {
                                return of(new ExecutionStepCompletedAction(appID, firstLevelStepID));
                            }
                            break;
                        case "FAILED":
                            return of(new ExecutionStepFailedAction(appID, firstLevelStepID, message));
                        case "READY":
                            return of(new ExecutionStepStartedAction(appID, firstLevelStepID));
                    }
                } else if (data.status === "DOCKER_PULL_FAILED") {
                    const {retry} = data as DockerPullTryLogEntry;
                    return of(new ExecutionDockerPullTimeoutAction(appID, Date.now() + retry * 1000));
                }

                return empty();

            })
        );
    }
开发者ID:hmenager,项目名称:composer,代码行数:68,代码来源:executor-output-parser.service.ts

示例9: ExecutionPreparedAction


//.........这里部分代码省略.........
                model.class as AppType,
                stepList,
                executionParams.outDir
            ));

            const startRunner = executor.execute(content, jobValue, executionParams).catch(ex => {
                processStillRunning = false;
                throw ex;
            });

            startRunner.then(runner => {

                if (obs.closed) {
                    return;
                }

                this.store.dispatch(new ExecutionStartedAction(appID));

                execution = runner;

                const process = execution.run();

                obs.next(execution.getCommandLineString());

                process.on("exit", (code: number, sig) => {
                    processStillRunning = false;

                    /** Successful completion if exit code is 0 */
                    const isCompleted = code === 0;

                    /**
                     * Killing a process manually will throw either exitCode 143, or
                     * a SIGINT/SIGTERM/SIGKILL in different circumstances, so we check for both
                     * */
                    const isCancelled = code === 143 || sig;


                    if (isCompleted) {
                        this.store.dispatch(new ExecutionCompletedAction(appID));
                        obs.complete();
                        return;

                    } else if (isCancelled) {
                        /**
                         * Cancellation is initially triggered from unsubscribing from killing the process
                         * when unsubscribing from the observable.
                         * ExecutionStopAction is therefore dispatched from the original place.
                         * @see executionUnsubscribe
                         */
                        obs.complete();
                        return;
                    } else {
                        this.store.dispatch(new ExecutionErrorAction(appID, new ExecutionError(code)));
                        obs.error(new Error(`Execution failed with exit code ${code}.`));
                    }

                });

                process.on("error", (err: any) => {
                    if (err.code === "ENOENT" && err.path === "java") {
                        obs.error(new Error("Cannot run Java process. Please check if it is properly installed."));
                        return;
                    }

                    obs.error(new Error(err));
                });

                process.stdout.on("data", data => {
                    obs.next(data.toString());
                });

                process.stderr.on("data", data => {
                    const output = data.toString();
                    this.store.dispatch(new ExecutorOutputAction(appID, output, "stderr"));
                });

            }, ex => {
                this.store.dispatch(new ExecutionRequirementErrorAction(appID, ex.message));
                obs.error(new Error(ex));
            });

            const cleanup = () => {
                if (processStillRunning) {
                    this.store.dispatch(new ExecutionStoppedAction(appID));
                }

                if (execution) {
                    execution.kill();
                }
                obs.complete();
            };

            this.actions.ofType(EXECUTION_STOP).pipe(
                filter((action: ExecutionStopAction) => action.appID === appID),
                take(1)
            ).subscribe(() => cleanup());

            /** @name executionUnsubscribe */
            return () => cleanup();
        });
开发者ID:hmenager,项目名称:composer,代码行数:101,代码来源:executor.service.ts


注:本文中的@ngrx/effects.Actions.ofType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。