![](/img/trans.png)
[英]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.