- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个相关的操作,应该依次触发。
我想使用@effects
或reducers
来做到这一点
在我的 slider.component 中,我触发第一个父操作
valueChange(event: MatSliderChange) {
this.store.dispatch(
new SetSelectDateTime({ dateSelect: this.date, timeSelect: event.source.displayValue })
);
}
然后在 reducer 中
case ESelectDateTimeActionTypes.SetSelectDateTime: {
return {
...state,
dateTimeSelect: action.payload
};
}
现在我应该根据所选时间触发第二个操作来获取新数据所以我创建了一个效果 updateActualTrips
export class SchedulingsEffects {
constructor(
private actions$: Actions,
private apiCallsService: ApiCallsService
) {}
loadSchedulings$ = createEffect(() =>
this.actions$.pipe(
ofType(ESchedulesActions.GetSchedulesByDate),
mergeMap(() =>
this.apiCallsService.getSchedulings().pipe(
map(trips => ({ type: ESchedulesActions.GetSchedulesByDateSuccess, payload: trips })),
catchError(() => EMPTY)
)
)
)
);
$LoadKpiMission = createEffect(() =>
this.actions$.pipe(
ofType<any>(EKpiActions.GetMissionsByStation),
mergeMap(action =>
this.apiCallsService.getKpiMissionByStation(action.payload, '2016-04-18').pipe(
map(trips => ({ type: EKpiActions.GetMissionsByStationSuccess, payload: trips })),
catchError(() => EMPTY)
)
)
)
);
$updateActualTrips = createEffect(() =>
this.actions$.pipe(
ofType<any>(ESelectDateTimeActionTypes.SetSelectDateTime),
map(action => ({ type: ESchedulesActions.GetNextSchedulesByTime, payload: action.payload }))
)
);
}
问题是效果从未触发,但所选时间已更新
更新我注意到当 SetSelectDateTime
初始化时第一次触发该效果
最佳答案
在您的示例代码中,等待操作 ESchedulesActions.GetNextSchedulesByTime
没有任何效果,您等待的唯一其他操作是 ESchedulesActions.GetSchedulesByDate
和 EKpiActions.GetMissionsByStation
。
您是否在这里缺少实际效果,或者我们没有看到完整的代码?调度 SetSelectDateTime
时,代码中的任何内容都不会向 API 请求新数据。
或者您是说 ESchedulesActions.GetNextSchedulesByTime
从未分派(dispatch)到存储(当运行 SetSelectDateTime
的效果监听时)?
关于javascript - 在 ngrx 中链接两个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58605125/
我已经建立了这个IStore: export interface IStore { user: IUser; sources: ISourceRedux; } 其中IUser是: export
store.select()发出先前的存储状态。 是否可以订阅从“此刻开始”的更改,而无需获取先前的商店值(value)? 最佳答案 如果您对第一个发出的值不感兴趣,则应该可以使用 skip 运算符:
我已将我的 ngrx 代码更新到版本 8(使用 Action Creator 等),但我现在不知道如何在 NgRx Store DevTools 中使用 Dispatcher。 在我能够发送这样的操作
我正在开发一个新的 angular 4 plus @ngrx 4 项目。 我希望对加载的数据具有搜索功能。 例如,所有联系人信息都已加载到组件中。 联系人列表将过滤与搜索文本匹配的联系人姓名。 Ple
我正在使用 Ngrx 和 Angular2 构建一个移动应用程序。当用户从我的应用程序中注销时,我想清除商店?谁能知道该怎么做? 最佳答案 您应该在每个 reducer 中有一个明确的操作,这将清理商
我看到很多代码示例,其中 store.dispatch() 调用直接发生在 Angular 组件中。让一个愚蠢的 Angular 组件访问整个 Store 不是很糟糕吗?为什么不将所有的 Action
ngrx 的支持者声称 (here for example),您可以并且应该将所有应用程序状态保存在单个 Store 中。这表明 @ngrx/Store 可以用于缓存,因为缓存的内容是一种应用程序状态
我的应用程序在调度某个 Action 时没有调度某些 Action 或某些效果没有被调用,这有问题(请参阅 ngrx effect not being called when action is di
下面的代码片段有什么作用?取自此 file . export const getCollectionLoading = createSelector(getCollectionState, fromC
如果在同一个商店上分派(dispatch)多个操作: store.dispatch(new SomeAction()); store.dispatch(new SomeOtherAction());
我试图了解 typeof 效果在 ngrx 中是如何工作的,如果我在我的应用程序模块中声明: .... @NgModule({ imports: [ EffectsModule
任何人都可以建议在角度应用程序中使用 ngrx 进行状态管理时如何控制台记录状态。我已经浏览了 ngrx-store-logger,但是文档并不清楚如何创建元 reducer 和使用这个库。 最佳答案
我一直在阅读ngrx示例应用程序的代码并找到两个函数调用 createFeatureSelector('auth'); 和 createSelector(selectAuthState,(state:
我正在使用 Angular 8 和 NGRX 8。我有一个操作: export const loadEnvironment = createAction( LicencingActionTypes
我正在使用 Angular 8 和 NGRX 8。我有一个操作: export const loadEnvironment = createAction( LicencingActionTypes
以下示例取自 @ngrx example . 我以这种方式理解这个 observable。第一map函数获取 payload这是要添加的书,再次由mergeMap处理它保存到数据库的位置。 原码:
我目前正在使用 NgRx Data 对我项目中的几个实体执行 CRUD 操作。现在,我必须开发分页。因此,REST API 响应将如下所示: { "page": 1, "per_pag
如何在 NGRX 中访问(读取)另一个 reducer 中的 reducer 状态?这是一个与 this 非常相似的问题.NGRX 是否为此提供任何其他解决方案? 最佳答案 我在考虑做类似的事情时偶然
我正在尝试按属性过滤掉有效负载数据。 //reducer.ts case MessagesActionTypes.LOAD_Message_SUCCESS: { console.lo
我有效果类,我想根据路由器参数 ID 加载详细信息 @Effect() getDetails$ = this.actions$.ofType(DetailActions.GET_DETAILS).
我是一名优秀的程序员,十分优秀!