问题
I'm currently using this to perform notifications:
/**
* Create notifications that broacast
* the entire set of entries.
*/
protected notify = new ReplaySubject<E[]>(1);
IIUC I can switch out the ReplaySubject<E[]>(1) with AsyncSubject<E[]>()?
Would this be an apple to apple switch or might here be semantic differences?
回答1:
No, they're very much not the same.
ReplaySubject(1) will always replay the latest emission no matter when the observer subscribes. It can emit any number of times.
AsyncSubject ignores all emissions until the observable completes, then emits the last emitted value. It can only ever emit once (at most) and when it does, it will also complete.
来源:https://stackoverflow.com/questions/52335556/is-replaysubject1-the-same-as-asyncsubject