打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SAP 电商云 Spartacus UI 和路由相关的 State 处理

state,effects,action,reducer 都在这个文件夹里:

在 routing-state.ts 里定义了 RouterState 接口:

继承自 ngrx router 里的 RouterReducerState 类型,类型参数为我们自定义的 ActivatedRouterStateSnapshot.

export interface ActivatedRouterStateSnapshot {
  url: string;
  queryParams: Params;
  params: Params;
  context: PageContext;
  cmsRequired: boolean;
  semanticRoute?: string;
}

看个例子:

interface myType<T,V>{
  name: T,
  value: V
};

interface jerryType extends myType<string, number>{
  score: number;
}

const a: jerryType = {
  name: 'Jerry',
  value: 1,
  score: 2
};

其中 state 的类型,需要定义 RouterReducerState 的扩展类型时传入:

BaseRouterStoreState 类型:只有一个 url 字段:

我们自定义的 ActivatedRouterStateSnapshot,extends 了 BaseRouterStoreState,第一个字段就为 url:

看个例子:

type jerryType = {
  name: string
};
interface mySuperType<T extends jerryType>{
  value: T
};

type superJerryType = {
  score: number;
  name: string;
}

let a: mySuperType<superJerryType> = {
  value:{
    score: 1,
    name: 'Jerry'
  }
};

console.log(a);
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
JAVA版微信支付V3-完全版
HttpClient PostMethod 传递json
Golang反射模型
Android异步下载网络图片(其二)
struts2采用注解方式配置url和Action的映射
go的R方法的使用
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服