Ngrx Store和Ionic 3-将reducer添加到app.module时未处理的Promise拒绝

时间:2018-10-06 16:53:27

标签: javascript angular ionic3 ngrx-store

我有一个ionic3项目,我正在尝试使用ngrx-store。我创建了一个简单的reducer,action,model和app.state。当我 just 将reducer添加到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;
        }
    } 

有什么建议可以尝试吗?

让我知道代码的其他任何部分是否可能有助于提出建议。

0 个答案:

没有答案