现在我要做的只是在myAPI.postUserData(action.payload)之前;我想调用PROFILE_FETCHING_DATA_LOADING来显示ActivityIndicator,但我无法执行此操作。
const profileFetchingDataEpic = (action$) =>
action$.pipe(
ofType(PROFILE_FETCHING_DATA_ATTEMPT),
flatMap((action) => {
myAPI.postUserData(action.payload);
return [action];
}),
map((action) => {
console.log("EPIC profileFetchingDataEpic", action);
return {
type: PROFILE_FETCHING_DATA_SUCCESS,
payload: action.payload,
};
})
);
任何想法的人
我不确定我是否正确理解您的100%。如果要由一个可观察的发射创建多个发射,则可以:
const { Observable } = rxjs;
const { mapTo, mergeAll } = rxjs.operators;
const source$ = new Observable(sub => sub.next(void 0)).pipe(
mapTo(['one', 'two']),
mergeAll()
)
source$.subscribe(v => console.log('source$', v))
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.5.3/rxjs.umd.min.js"></script>
mapTo
代表您的map((action) => ...
。在这里,您需要创建要在特定操作传入后发出的所有操作。