I'm trying to figure out how - using RxJS 6 - to check a cache for a value and only if the value isn't found in the cache, request the value from the database. Ideally, I'd then be able to add the value received from the DB to the cache.
So far, I've looked at race
, but that's going to request both and take whichever responds first. I don't want to request from the DB if the value is available in cache. flatMap
seems to have the same issue?
I'm aware of defaultIfEmpty
but that only provides a default value, not subscribe to a new Observable and emit those values instead.
Thanks,
TTE