rxjs v6 / redux-observable v1.0.0:运算符在史诗中不起作用
rxjs v6 / redux-observable v1.0.0: Operators not working in epic
我正在使用最新版本的 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' })
);
所以当我第一次执行程序时,我得到了以下错误:
我用谷歌搜索了一下,found a solution here 说要安装 rxjs-compat@6
(但没有任何意义)我也安装了它!然后我 运行 进入以下错误:
.
我不知道what/where我做错了吗?任何帮助将不胜感激!
谢谢
应该是
import { mapTo } from 'rxjs/operators';
而不是
import { mapTo } from 'rxjs/operator/mapTo';
来源:https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#usage
我正在使用最新版本的 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' })
);
所以当我第一次执行程序时,我得到了以下错误:
我用谷歌搜索了一下,found a solution here 说要安装 rxjs-compat@6
(但没有任何意义)我也安装了它!然后我 运行 进入以下错误:
我不知道what/where我做错了吗?任何帮助将不胜感激!
谢谢
应该是
import { mapTo } from 'rxjs/operators';
而不是
import { mapTo } from 'rxjs/operator/mapTo';
来源:https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#usage