1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

RxJS cache and refresh with shareReplay

Discussão em 'Angular' iniciado por Ravid Goldenberg, Outubro 2, 2024.

  1. I am using a caching for some data retrieved from an API, for logical reasons the stored data is valid only for a limited time, so I am making use of something like:

    someApiData$ = this.getData()
    .pipe(shareReplay(1, 3000))


    What seems to be obvious to me but apparently is not to the creator of the shareReplay operator is that if the data is no longer cached it should be re-fetched, or at the very least I should have another parameter that will give me this option, something like:

    someApiData$ = this.getData()
    .pipe(shareReplay(1, 3000, shouldRefresh))


    Instead, what the next subscriber will get is null. So, I am looking for an elegant solution to this issue.

    Continue reading...

Compartilhe esta Página