Re:Ask HN: What are some cool but obscure data structures yo...
by MobiusHorizons on Friday July 22, 2022 @12:00PM
(#32193473)
I have a similar pattern when using an rxjs pipeline to do async tasks in response to changes in other values. The typical pattern would be
Where doTask returns a promise or an AsyncSubject. The shareRelpay allows foo to cache the last value so any late subscriber will get the most recent value. This has a problem of returning cached values while new work is happening (eg while a network request is in progress) so instead I like to write
This way the shareReplay is caching the promise instead of the result. With this pattern I can interact with this pipeline from code like so
Without the pattern, this code would get the old result if there was ever any cached value
[ Parent
| on HN ]
There are no comments on this comment yet.