我的史诗如下
export const fetchSomethingEpic = (action$, state$) => {
return action$.pipe(ofType(someActions.FETCH_LEADS),
mergeMap(action =>
from(api().get('SOMETHING'))
.map(response => fetchSomethingSuccess(response.data))
.catch(error => Observable.of(fetchSomethingError(error))))
);
}这里是axios.create,它发生在另一个文件中。
基本上,当我安装rxjs-compat时,这是非常完美的。但是试图删除它,现在给了我以下错误
TypeError: Object(...)(...).map is not a function在安装了rxjs-compat之后,它就在哪里工作
我有
import { Observable } from 'rxjs/Rx';
import { mergeMap } from 'rxjs/operators';
"rxjs": "6.2.1",
"rxjs-compat":"6.2.1"现在我有了
import { Observable } from 'rxjs'
import { mergeMap, map} from 'rxjs/operators';
"rxjs": "^6.5.2"我是不是漏掉了什么
发布于 2019-08-07 09:03:48
按以下方式解决
export const fetchSomethingEpic = (action$) =>
action$.ofType(someActions.FETCH_LEADS)
.pipe(mergeMap((action) => from(api().get('SOMETHING'))
.pipe(map(response => fetchSomethingSuccess(response.data)),
catchError(error => fetchSomethingError(error))))
);发布于 2019-08-06 03:36:32
您必须使用pipe传递可观察到的使用map运算符。还导入catchError以处理错误。
export const fetchSomethingEpic = (action$, state$) => {
return action$.pipe(ofType(someActions.FETCH_LEADS),
mergeMap(action =>
from(api().get('SOMETHING'))
.pipe(map(response => fetchSomethingSuccess(response.data)),
catchError(error => Observable.of(fetchSomethingError(error))))
);
}https://stackoverflow.com/questions/57312163
复制相似问题