[英]How can I chain RxJS observable in a redux-observable epic?
[英]How to wait or listen for Url has changed using rxjs and redux-observable?
我收到響應數據后並轉到另一頁后,試圖顯示模式彈出窗口。 正確實施此功能很熱嗎?
我使用React-observable和rxjs 。 我確實使用請求服務器和更改history.location來創建史詩。 工作正常
action$.pipe(
ofType(myActionLading),
mergeMap(action => of(convertDataToServer(action.payload))),
mergeMap(data =>
from(convertToDataAPI(data)).pipe(
mergeMap(response => of(convertCustomerFromServer(response.
mergeMap(() => {
return of(
actionGetDataInfoLoading({ id }),
);
}),
tap(() => history.push('/newRoute')),
takeUntil(// I have to verify if I am already on my newRoute and then show the popUp),
finalize(() => console.log('!!! FIN !!!') ||
modals.getModalSuccess()),
),
),
在上一條新路線后,我想看到“成功”模態彈出窗口。 所以我想聽history.push,或驗證我是否在新路線上,然后才顯示模態
我不認為有可能按照您解釋它的方式執行該邏輯(至少使用react-router
)。
但是,如果僅通過此操作成功才能訪問/newRoute
則可以在安裝與newRoute
對應的組件時打開模式。
否則,請提供查詢參數以確定您是否要打開模式。
例如:
// someEpic.js
tap(() => history.push('/newRoute?showModal=true')
...
//newRoute.jsx (The component)
export class NewRoute extends React.Component {
...
componentWillMount() {
const showModal = this.props.... // logic to get query param of showModal.
if (showModal) {
modals.getModalSuccess();
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.