我是redux-observable的新手,我创造了一部新的史诗。 我的代码显示'(0,rxjs.ofType)不是函数。 但是,我复制了那个
= (action$: Observable<Action>, store: any) => action$.pipe(
ofType('SUCCESS_LOGIN'),
来自另一个不显示错误的文件。
有什么问题?
// @flow
import { combineEpics } from 'redux-observable';
import { Observable, ofType } from 'rxjs';
import { map, exhaustMap } from 'rxjs/operators';
import camelcaseKeysDeep from 'camelcase-keys-deep';
import * as actions from './actions';
import { request } from '../../lib/axios';
const getDeviceTokenEpic = (action$: Observable<Action>, store: any) => action$.pipe(
ofType('SUCCESS_LOGIN'),
exhaustMap(({ payload }) => request({
url: `users/${store.getState().currentUser.user.id}`,
method: 'put',
data: {
device_token: 'test',
password: 'test',
},
}).pipe(
map(data => camelcaseKeysDeep(data)),
map(({ user, authToken }) => currentUserActions.successLogin({ user, authToken })),
catchError((errorMessage: string) => Observable.of(actions.failLogin({ errorMessage }))),
)),
);
export default combineEpics(
getDeviceTokenEpic,
);
答案 0 :(得分:0)
正如@cartant所说,ofType
的功能来自redux-observable
!
只需将其更改为:
import { ofType } from "redux-observable";