不能将 redux-observable 与 Stencil@one 一起使用:"Class constructor Observable cannot be invoked without 'new'" ActionsObservable 上的错误 class
Can't use redux-observable with Stencil@one : "Class constructor Observable cannot be invoked without 'new'" error on ActionsObservable class
我有一个使用@Stencil/redux、redux、redux-observable 和redux-actions 的Stencil 组件库。之前一切正常,但我正在尝试升级到 Stencil@One (1.0.0-beta.5)。
我现在在创建 Redux 存储期间遇到错误。这是我的商店配置:
import { Store, createStore, applyMiddleware } from 'redux';
import { createEpicMiddleware } from 'redux-observable';
import { rootEpic } from './epic';
const epicMiddleware = createEpicMiddleware();
export const ogodStore: Store<OgodState> = createStore(rootReducer, applyMiddleware(epicMiddleware));
epicMiddleware.run(rootEpic);
调用 applyMiddleware 时发生错误,错误如下:
TypeError: Class constructor Observable cannot be invoked without 'new'
at new ActionsObservable (chunk-f18fe9c6.js:3744)
at epicMiddleware (chunk-f18fe9c6.js:3830)
at chunk-f18fe9c6.js:4579
at Array.map (<anonymous>)
at chunk-f18fe9c6.js:4578
at createStore (chunk-f18fe9c6.js:4043)
at chunk-f18fe9c6.js:4716
这些年来,我对不同的 javascript 模块类型和目标感到非常困惑......但这是我所知道的:
- 此错误是由 redux-observable 中的这段特定代码引起的:
(ActionsObservable.__proto__ || Object.getPrototypeOf(ActionsObservable)).call(this)
- 是用
call(this)
构造一个ActionsObservable对象,依赖rxjs的Observable
class
- 在我的 Typescript 配置中,我使用了 stencil 创建的内容,它对于新项目仍然是相同的(模块:'esnext',目标:'es2017')
Observable
来自 rxjs 不支持这个?!它是一个 class 应该使用 ES6 语法构建 new
因为它现在被浏览器支持了?
我真的很想知道我是否应该在 redux-observable 的 Github 中创建一个问题?
已创建 issue,因为没有人回答。希望我们能尽快得到消息...
我按照@Elvynia 提供的 github link 解决了这个问题 -
安装 redux-observable-es6-compat 并导入 -
import { createEpicMiddleware, combineEpics } from 'redux-observable-es6-compat';
而不是
import { createEpicMiddleware, combineEpics } from 'redux-observable';
我有一个使用@Stencil/redux、redux、redux-observable 和redux-actions 的Stencil 组件库。之前一切正常,但我正在尝试升级到 Stencil@One (1.0.0-beta.5)。
我现在在创建 Redux 存储期间遇到错误。这是我的商店配置:
import { Store, createStore, applyMiddleware } from 'redux';
import { createEpicMiddleware } from 'redux-observable';
import { rootEpic } from './epic';
const epicMiddleware = createEpicMiddleware();
export const ogodStore: Store<OgodState> = createStore(rootReducer, applyMiddleware(epicMiddleware));
epicMiddleware.run(rootEpic);
调用 applyMiddleware 时发生错误,错误如下:
TypeError: Class constructor Observable cannot be invoked without 'new'
at new ActionsObservable (chunk-f18fe9c6.js:3744)
at epicMiddleware (chunk-f18fe9c6.js:3830)
at chunk-f18fe9c6.js:4579
at Array.map (<anonymous>)
at chunk-f18fe9c6.js:4578
at createStore (chunk-f18fe9c6.js:4043)
at chunk-f18fe9c6.js:4716
这些年来,我对不同的 javascript 模块类型和目标感到非常困惑......但这是我所知道的:
- 此错误是由 redux-observable 中的这段特定代码引起的:
(ActionsObservable.__proto__ || Object.getPrototypeOf(ActionsObservable)).call(this)
- 是用
call(this)
构造一个ActionsObservable对象,依赖rxjs的Observable
class - 在我的 Typescript 配置中,我使用了 stencil 创建的内容,它对于新项目仍然是相同的(模块:'esnext',目标:'es2017')
Observable
来自 rxjs 不支持这个?!它是一个 class 应该使用 ES6 语法构建 new
因为它现在被浏览器支持了?
我真的很想知道我是否应该在 redux-observable 的 Github 中创建一个问题?
已创建 issue,因为没有人回答。希望我们能尽快得到消息...
我按照@Elvynia 提供的 github link 解决了这个问题 -
安装 redux-observable-es6-compat 并导入 -
import { createEpicMiddleware, combineEpics } from 'redux-observable-es6-compat';
而不是
import { createEpicMiddleware, combineEpics } from 'redux-observable';