我正在使用最新版本的redux-observable和Rxjs,即
// My version
"redux-observable": "^1.0.0",
"rxjs": "^6.3.2"
商店-中间件的设置如下:
// Setting up middlewares
import { pingEpic } from './epics';
import pingReducer from './reducers/pingReducer';
import { combineReducers, createStore, applyMiddleware } from 'redux';
import { combineEpics, createEpicMiddleware } from 'redux-observable';
const rootReducer = combineReducers(pingReducer);
const rootEpic = combineEpics(pingEpic);
const epicMiddleware = createEpicMiddleware();
const store = createStore(rootReducer,
applyMiddleware(epicMiddleware)
);
epicMiddleware.run(rootEpic);
export default store;
我的史诗看起来像这样
// pingEpic.js
import { mapTo } from 'rxjs/operator/mapTo';
import { ofType } from 'redux-observable';
export const pingEpic = action$ => action$.pipe(
ofType('PING'),
mapTo({ type: 'PONG' })
);
因此,当我第一次执行程序时,出现以下错误:
我用Google搜索它,然后found a solution here表示要安装rxjs-compat@6
(但是这没有任何意义),我也安装了它!然后我遇到了以下错误:
我不知道我在哪里/哪里做错了?任何帮助将不胜感激!
谢谢
答案 0 :(得分:2)
应该是
import { mapTo } from 'rxjs/operators';
代替
import { mapTo } from 'rxjs/operator/mapTo';
来源:https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#usage