本文整理汇总了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;未经允许,请勿转载。 |
请发表评论