planttheidea/moize

[Feature request] Conditionally use `maxAge`

Closed this issue · 1 comments

I would like to use maxAge depending on a condition. For example: do not use maxAge when network is temporarily offline, use it otherwise.

Note that this condition:

  • is not constant, i.e. I cannot set it when moize is initialized. For example, maybe when I called moize() the network was not offline yet, but one hour later it is now offline.
  • does not depend on the cache key, so onExpire() cannot be used.

Possible solutions:

  • allow maxAge to be a function returning a number (including Infinity)
  • add a useMaxAge(functionArgs) => boolean, or similar
  • anything else you might think of :)

Thanks for this great library!

It turns out don't need this feature in my code because I don't actually need offline support. I am closing this issue.