How to handle circularly dependent observables in RxJS?

和自甴很熟 提交于 2019-12-04 17:28:43

Introduce a Subject as a proxy at some point in the cycle in the dependency graph, then mirror the behavior of the real Observable (cache$) onto the proxy Subject (proxyCache$).

const input$          = Rx.Observable.fromEvent(..., "input");
const proxyCache$     = new Rx.Subject();
const request$        = input$.merge(proxyCache$).map( ... );
const serverResponse$ = request$.flatMap( askServer );
const cache$          = serverResponse$.scan( ... );
cache$.subscribe(proxyCache$);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!