當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript effects.Effect函數代碼示例

本文整理匯總了TypeScript中@ngrx/effects.Effect函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Effect函數的具體用法?TypeScript Effect怎麽用?TypeScript Effect使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Effect函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: persistTodos

 @Effect({ dispatch: false })
 persistTodos() {
   return this.actions$.pipe(
     ofType<ActionTodosPersist>(TodosActionTypes.PERSIST),
     tap(action =>
       this.localStorageService.setItem(TODOS_KEY, action.payload.todos)
     )
   );
 }
開發者ID:NLPDev,項目名稱:toHeroku,代碼行數:9,代碼來源:todos.effects.ts

示例2: login

 @Effect({ dispatch: false })
 login() {
   return this.actions$.pipe(
     ofType<ActionAuthLogin>(AuthActionTypes.LOGIN),
     tap(() =>
       this.localStorageService.setItem(AUTH_KEY, { isAuthenticated: true })
     )
   );
 }
開發者ID:NLPDev,項目名稱:toHeroku,代碼行數:9,代碼來源:auth.effects.ts

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: logout

 @Effect({ dispatch: false })
 logout() {
   return this.actions$.pipe(
     ofType<ActionAuthLogout>(AuthActionTypes.LOGOUT),
     tap(() => {
       this.router.navigate(['']);
       this.localStorageService.setItem(AUTH_KEY, { isAuthenticated: false });
     })
   );
 }
開發者ID:NLPDev,項目名稱:toHeroku,代碼行數:10,代碼來源:auth.effects.ts

示例8: 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

示例9: 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

示例10: 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


注:本文中的@ngrx/effects.Effect函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。