-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Inside RRR there are two logics that are fighting with each other a little bit:
- one is stale while invalidate
- will use existing resource if it’s available and not expired
if (cached && shouldUseCache(cached)) { - or will “fallback” to the exiting while loading the new one
data: maxAge === 0 ? null : prevSlice.data,
- will use existing resource if it’s available and not expired
- another one proactively removes all already expired pieces
if (slice && (!slice.expiresAt || slice.expiresAt < Date.now())) { - so the logic mentioned above will have “nothing”
Questions
-
there is a comment that we "need" to clean resourced during transition
https://github.com/atlassian-labs/react-resource-router/blob/b0e55faeafdc6f193e5fda338e5533e6f88725cf/src/resources/controllers/resource-store/index.tsx#L427C1-L431C25- "why?"
-
there is a logic that can reuse previous response while the new one is loading
- probably this is how
refresh
works. More likely intentional. - this logic is never used during transition. Is it intentional?
- probably this is how
-
if one removes
cleanExpiredResources
- would it lead to any memory leaks?
- would it lead to any behavior change?
- and if yes (and it will), how end user can detect such change
Proposal - add explicit stateWhileInvalidate
flag for resource
and exempt them from cleanExpiredResources
giving control to the end user.
Metadata
Metadata
Assignees
Labels
No labels