SAP Spartacus名为Configuration的injection token
Configuration injection token创建的factory方法:
factory方法返回的值是{}, inject(DefaultConfig)和inject(RootConfig)三者的深度merge.
而DefaultConfig和ConfigChunk又是另外两个新的injection token:
对于DefaultConfigChunk,有太多的module贡献在这个配置上了:DefaultConfigurationChunk:
一个具体的例子:
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { StateConfig, StorageSyncType } from '../../state/config/state-config';
import { StateModule } from '../../state/state.module';
import { ASM_FEATURE } from './asm-state';
import { effects } from './effects/index';
import { metaReducers, reducerProvider, reducerToken } from './reducers/index';
import { provideDefaultConfigFactory } from '../../config/config-providers';export function asmStoreConfigFactory(): StateConfig {const config: StateConfig = {state: {storageSync: {keys: {'asm.asmUi': StorageSyncType.LOCAL_STORAGE,'asm.csagentToken.value.access_token': StorageSyncType.LOCAL_STORAGE,'asm.csagentToken.value.token_type': StorageSyncType.LOCAL_STORAGE,'asm.csagentToken.value.expires_in': StorageSyncType.LOCAL_STORAGE,'asm.csagentToken.value.expiration_time':StorageSyncType.LOCAL_STORAGE,'asm.csagentToken.value.scope': StorageSyncType.LOCAL_STORAGE,'asm.csagentToken.value.userId': StorageSyncType.LOCAL_STORAGE,},},},};return config;
}
@NgModule({imports: [CommonModule,HttpClientModule,StateModule,StoreModule.forFeature(ASM_FEATURE, reducerToken, { metaReducers }),EffectsModule.forFeature(effects),],providers: [provideDefaultConfigFactory(asmStoreConfigFactory),reducerProvider,],
})
export class AsmStoreModule {}
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
SAP Spartacus名为Configuration的injection token相关推荐
- SAP Spartacus Static Multi-Site Configuration
官方链接 Static Multi-Site Configuration 您可以通过定义上下文属性(例如基本站点.语言和货币)来配置您的应用程序. 当您将这些属性的值附加到店面 URL 时,店面将根据 ...
- SAP Spartacus OCC 请求头部的 Access Token 是如何被添加的
本文讨论下图这些高亮的 Authorization 头部字段,是如何被用户登录后从 commerce 端请求的 Access Token 填充的: 这些 interceptor 通过 HTTP_INT ...
- SAP Spartacus localStorage 里存储的 auth Token 过期时间
Chrome 开发者工具里存储了access token 存储的时间和过期时间: access_token_stored_at expires_at 这两个字段的值,放到 Date 构造函数内,打印出 ...
- SAP Spartacus里使用injection token提供默认配置的一个例子
以AsmStoreModule为例: import { CommonModule } from '@angular/common'; import { HttpClientModule } from ...
- SAP Spartacus 中的依赖注入 Dependency Injection 介绍
先了解 Angular 中的依赖注入 依赖项是指某个类执行其功能所需的服务或对象.依赖项注入(DI)是一种设计模式,在这种设计模式中,类会从外部源请求依赖项而不是让类自己来创建它们. Angular ...
- SAP Spartacus 3.0 的一些变化
SAP Spartacus 确实使用到了Bootstrap这个框架: Technical Changes in Spartacus 3.0 Breaking Changes Translations ...
- SAP Spartacus 如何使用 API 从浏览器 local Storage 读取数据
如下图所示,SAP 电商云 UI,用户的购物车 ID,持久化在浏览器的 local storage 里: 运行时,通过封装好的函数 getStorage 读取: 为什么会触发 State module ...
- 手动为 SAP Spartacus 添加 SSR 支持的步骤
ng add @spartacus/schematics --ssr 在用 SAP Spartacus 开发的 store 里,能看到 devDependencies 里具有 @spartacus/s ...
- SAP Spartacus 用户认证的实现
文章目录 UserAuthModule Authentication Flow AuthService Storing Tokens and User Identifiers 用户认证的典型流程和包含 ...
最新文章
- 使用Lucene.Net实现全文检索
- qstring如何初始化_QString介绍
- zip unzip 命令
- EWSD常用状态解释
- 【机器学习入门笔记6:OpenCV像素的读取与写入】20190204
- unistd.h 中int access(const char * pathname, int mode); 判断进程能否以mode模式访问pathname文件(可以用来判断文件/目录是否存在)...
- java 正则表达式 替换字符串img标签的路径_python面试题汇总第06期-正则表达式(内附7题及答案)...
- JVM之垃圾收集机制四种GC算法详解
- 基于visual Studio2013解决面试题之0608找出两个只出现一次的数
- 代码中大量的if/else,你有什么优化方案?
- 解决安装并配置好 hb后,hb -h检测不对
- Android APK XML解析与反编译方法
- sip协议详解_WebRTC SDP 详解和剖析
- Default clip could not be found in attached animations list...must be marked as legacy解决办法
- matlab矩形频谱图,如何用matlab画出周期矩形脉冲信号及频谱图?
- 织梦dedecms调用热门搜索关键词的方法
- 单片机led灯闪烁实验总结_项目二 LED灯闪烁设计实现
- 微信小程序 满意度调查问卷
- word文档怎么到下一页去写_word文档怎么插入下一页
- Beta周王者荣耀交流协会第五次Scrum会议