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相关推荐

  1. SAP Spartacus Static Multi-Site Configuration

    官方链接 Static Multi-Site Configuration 您可以通过定义上下文属性(例如基本站点.语言和货币)来配置您的应用程序. 当您将这些属性的值附加到店面 URL 时,店面将根据 ...

  2. SAP Spartacus OCC 请求头部的 Access Token 是如何被添加的

    本文讨论下图这些高亮的 Authorization 头部字段,是如何被用户登录后从 commerce 端请求的 Access Token 填充的: 这些 interceptor 通过 HTTP_INT ...

  3. SAP Spartacus localStorage 里存储的 auth Token 过期时间

    Chrome 开发者工具里存储了access token 存储的时间和过期时间: access_token_stored_at expires_at 这两个字段的值,放到 Date 构造函数内,打印出 ...

  4. SAP Spartacus里使用injection token提供默认配置的一个例子

    以AsmStoreModule为例: import { CommonModule } from '@angular/common'; import { HttpClientModule } from ...

  5. SAP Spartacus 中的依赖注入 Dependency Injection 介绍

    先了解 Angular 中的依赖注入 依赖项是指某个类执行其功能所需的服务或对象.依赖项注入(DI)是一种设计模式,在这种设计模式中,类会从外部源请求依赖项而不是让类自己来创建它们. Angular ...

  6. SAP Spartacus 3.0 的一些变化

    SAP Spartacus 确实使用到了Bootstrap这个框架: Technical Changes in Spartacus 3.0 Breaking Changes Translations ...

  7. SAP Spartacus 如何使用 API 从浏览器 local Storage 读取数据

    如下图所示,SAP 电商云 UI,用户的购物车 ID,持久化在浏览器的 local storage 里: 运行时,通过封装好的函数 getStorage 读取: 为什么会触发 State module ...

  8. 手动为 SAP Spartacus 添加 SSR 支持的步骤

    ng add @spartacus/schematics --ssr 在用 SAP Spartacus 开发的 store 里,能看到 devDependencies 里具有 @spartacus/s ...

  9. SAP Spartacus 用户认证的实现

    文章目录 UserAuthModule Authentication Flow AuthService Storing Tokens and User Identifiers 用户认证的典型流程和包含 ...

最新文章

  1. 使用Lucene.Net实现全文检索
  2. qstring如何初始化_QString介绍
  3. zip unzip 命令
  4. EWSD常用状态解释
  5. 【机器学习入门笔记6:OpenCV像素的读取与写入】20190204
  6. unistd.h 中int access(const char * pathname, int mode); 判断进程能否以mode模式访问pathname文件(可以用来判断文件/目录是否存在)...
  7. java 正则表达式 替换字符串img标签的路径_python面试题汇总第06期-正则表达式(内附7题及答案)...
  8. JVM之垃圾收集机制四种GC算法详解
  9. 基于visual Studio2013解决面试题之0608找出两个只出现一次的数
  10. 代码中大量的if/else,你有什么优化方案?
  11. 解决安装并配置好 hb后,hb -h检测不对
  12. Android APK XML解析与反编译方法
  13. sip协议详解_WebRTC SDP 详解和剖析
  14. Default clip could not be found in attached animations list...must be marked as legacy解决办法
  15. matlab矩形频谱图,如何用matlab画出周期矩形脉冲信号及频谱图?
  16. 织梦dedecms调用热门搜索关键词的方法
  17. 单片机led灯闪烁实验总结_项目二 LED灯闪烁设计实现
  18. 微信小程序 满意度调查问卷
  19. word文档怎么到下一页去写_word文档怎么插入下一页
  20. Beta周王者荣耀交流协会第五次Scrum会议

热门文章

  1. linux各种复制命令
  2. CentOS7 iso封装语句
  3. 年度榜单:2013年最流行的15款免费英文字体
  4. 开发---推荐16个国外的源码下载网站
  5. idea中隐藏.idea文件夹和.iml文件
  6. 知乎:GAN 的发展对于研究通用人工智能有什么意义?
  7. Centos7 Minimal 安装后 初始化配置
  8. 结对-贪吃蛇游戏-开发环境搭建过程
  9. fhq treap ------ luogu P3369 【模板】普通平衡树(Treap/SBT)
  10. hdu 1086 A - You can Solve a Geometry Problem too (线段的规范相交非规范相交)