带有redux的NativeScript ......收到错误

时间:2016-10-21 05:04:09

标签: redux nativescript

所以2天一直试图让Redux使用NativeScript和angular 2而没有运气......一切都在浏览器中工作正常但在NativeScript中没有...并且无法在整个网络上找到一个例子对于任何使用带有NS的redux的人......:/

这是错误

JS:     at /data/data/org.nativescript.groceries/files/app/Lib.js:23:62
JS:     at NgModuleInjector.Object.defineProperty.get (AppModule.ngfactory.js:210:61)
JS:     at NgModuleInjector.AppModuleInjector.getInternal (AppModule.ngfactory.js:284:48)
JS:     at NgModuleInjector.get (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/bundles/core.umd.js:7135:31)
JS:     at ElementInjector.get (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/bundles/core.umd.js:9208:52)
JS:     at ReflectiveInjector_._getByKeyDefault (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/bundles/core.umd.js:3297:28)
JS:     at ReflectiveInjector_._getByKey (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/bundles/core.umd.js:3263:29)
JS:     at ReflectiveInjector_.get (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/bundles/core.umd.js:3072:25)
JS:     at DebugAppView._View_LoginComponent_Host0.createInternal (LoginComponent_Host.ngfactory.js:16:189)
JS:     at DebugAppView.AppView.create (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/bundles/core.umd.js:9323:25)
JS: Error: Uncaught (in promise): Error: Error in ./LoginComponent class LoginComponent_Host - inline template:0:0 caused by: thunkMiddleware is not defined
我知道,信息量不大。 我想NativeScript的人会有一个使用redux的例子,但没有这样的运气。

我唯一可以工作的只是带有单个减速器的redux商店。 但是一旦我尝试组合Reducers或添加中间件,它就会爆炸......

不明白为什么

所有香草还原剂:

    const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware);
    const enhancers = compose(middlewareEnhancer);
    const createStoreWithEnhancers = enhancers(createStore);
    const reduxAppStore = createStoreWithEnhancers(reducerList);
    return reduxAppStore;

我欢迎任何帮助,但在这一点上,如果没有我可以使用的任何堆栈跟踪信息,我觉得这是一个失败的原因......

问候

肖恩

2 个答案:

答案 0 :(得分:0)

嘿Sean我已经在问题上回复了你 - https://github.com/NativeScript/NativeScript/issues/2939

让我们讨论一下。

答案 1 :(得分:0)

所以tx到vakrilov答案很简单。 设法通过添加

来解决它

global.process = { env: {} }

在所有导入之前的main.ts

现在这适用于NativeScript:)

... const reducers = combineReducers(reducerList); const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware); const enhancers = compose(middlewareEnhancer); const createStoreWithEnhancers = enhancers(createStore); const reduxAppStore = createStoreWithEnhancers(reducers); return reduxAppStore;