前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SAP Spartacus名为Configuration的injection token

SAP Spartacus名为Configuration的injection token

作者头像
Jerry Wang
发布2020-10-29 13:13:04
2980
发布2020-10-29 13:13:04
举报

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 {}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-10-25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档