javascript - Ngrx Store 和 Ionic 3 - 将 reducer 添加到 app.module 时未处理的 Promise 拒绝
问题描述
我有一个 ionic3 项目,我正在尝试使用 ngrx-store。我创建了一个简单的 reducer、action、model 和 app.state。当我将减速器添加到 app.module.ts时出现以下错误。减速器尚未在任何组件中使用。
Unhandled Promise rejection: Cannot read property 'schedule' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'schedule' of undefined
at ObserveOnSubscriber.scheduleMessage (observeOn.js:93)
at ObserveOnSubscriber._error (observeOn.js:99)
at ObserveOnSubscriber.Subscriber.error (Subscriber.js:106)
at ActionsSubject.Observable._trySubscribe (Observable.js:177)
at ActionsSubject.Subject._trySubscribe (Subject.js:97)
at ActionsSubject.Observable.subscribe (Observable.js:160)
at ObserveOnOperator.call (observeOn.js:69)
at AnonymousSubject.Observable.subscribe (Observable.js:157)
at WithLatestFromOperator.call (withLatestFrom.js:69)
at AnonymousSubject.Observable.subscribe (Observable.js:157) TypeError: Cannot read property 'schedule' of undefined
at ObserveOnSubscriber.scheduleMessage (http://localhost:8100/build/vendor.js:55994:33)
at ObserveOnSubscriber._error (http://localhost:8100/build/vendor.js:56000:14)
at ObserveOnSubscriber.Subscriber.error (http://localhost:8100/build/vendor.js:20763:18)
at ActionsSubject.Observable._trySubscribe (http://localhost:8100/build/vendor.js:331:18)
at ActionsSubject.Subject._trySubscribe (http://localhost:8100/build/vendor.js:23279:51)
at ActionsSubject.Observable.subscribe (http://localhost:8100/build/vendor.js:314:93)
at ObserveOnOperator.call (http://localhost:8100/build/vendor.js:55970:23)
at AnonymousSubject.Observable.subscribe (http://localhost:8100/build/vendor.js:311:22)
at WithLatestFromOperator.call (http://localhost:8100/build/vendor.js:92156:23)
at AnonymousSubject.Observable.subscribe (http://localhost:8100/build/vendor.js:311:22)
我有一个简单的减速器
import * as BudgetActions from './budget.actions'
import { BudgetCategory } from './budget.model'
export function budgetReducer(state: BudgetCategory[] = [], action : BudgetActions.Actions) {
switch(action.type) {
case BudgetActions.GET_ALL_BUDGET_CATEGORIES:
return state;
case BudgetActions.ADD_BUDGET:
return [...state, action.payload];
case BudgetActions.REMOVE_BUDGET:
//splice the budget based on the id in payload
return state;
case BudgetActions.STORE_ALL_BUDGET_CATEGORIES:
state = action.payload;
return state;
default:
return state;
}
}
请问有什么建议可以试试吗?
让我知道代码的任何其他部分是否有助于获得一些关于建议的想法。
解决方案
推荐阅读
- pandas - Pandas - 未找到列作为 groupby 的键
- c - 捕捉浮点数的精度损失
- java - Java 错误:IntelliJ IDEA 不支持发布版本 14
- html - flex 的第二行如何占用上面的空间
- javascript - iPad 上的简单 HTML5 视频播放列表
- css - 如何在 Superset 的仪表板中覆盖字体大小
- java - Apache POI SXSSFWorkbook 在 XLSX 文件内存问题中写入大约 500.000
- mvvm - 正确应用了 SwiftUI MVVM 模式?
- c# - 我们如何将命名空间写为动态命名空间
- python - 我可以通过应用 tanh(x) 来处理数据中的异常值吗?