[英]rxjs v6 / redux-observable v1.0.0: Operators not working in epic
I am using the latest version of redux-observable and Rxjs ie 我使用的是最新版本的redux-observable和Rxjs ie
// My version
"redux-observable": "^1.0.0",
"rxjs": "^6.3.2"
The store - middleware, setup looks like this: 商店 - 中间件,设置如下:
// 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;
And my epic looks like this 我的史诗看起来像这样
// pingEpic.js
import { mapTo } from 'rxjs/operator/mapTo';
import { ofType } from 'redux-observable';
export const pingEpic = action$ => action$.pipe(
ofType('PING'),
mapTo({ type: 'PONG' })
);
So when I executed the program for the first time I got the following error: 因此,当我第一次执行该程序时,我收到以下错误:
I googled it and found a solution here which says to install rxjs-compat@6
(however it doesn't makes any sense) I installed that too! 我用Google搜索并找到一个解决方案 ,说安装
rxjs-compat@6
(但它没有任何意义)我也安装了它! And then I ran into the following error: 然后我遇到了以下错误:
I don't know what/where am I doing wrong? 我不知道我做错了什么/哪里? Any help would be much appreciated!
任何帮助将非常感激!
Thanks 谢谢
It should be 它应该是
import { mapTo } from 'rxjs/operators';
instead of 代替
import { mapTo } from 'rxjs/operator/mapTo';
source: https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#usage 来源: https : //github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#usage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.