Replies: 2 comments
-
Add compatibility adapter to keep existing managers working with this new model; add some sort of detection so the builtin managers use the new path |
Beta Was this translation helpful? Give feedback.
0 replies
-
Controller.fetchIfStale is released in @data-client/react@0.4.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Originally posted as #2053
Motivation
Current world
Currently final ‘stale’ logic exists in hooks
This isn’t too bad; but it does mean some logic is repeated in any implementation.
The non-lifecycle based logic can be extracted as such:
Proposal
💡 Need feedback on name. I don’t like how long fetchIfStale is!Add a new controller dispatch that will only fetch if the result is stale. If it ends up not fetching the promise will immediately resolve.
Open questions
Dispatch resolution control
dispatch adds to action a callback. if this callback is called it returns the dispatch early.
Instead of
.e.g,
And you can still continue processing the request by doing the rest of it async
Doing this would also enable not having to send resolve/reject in fetch meta; but just take dispatch return value. This would be actual promise used by the NetworkManager so referential equality checks could be performed against it.
This means dispatch() now has a variable return type based on what the middlewares do. This could have weird implications for user-defined managers; so perhaps we should add type inference based on middlewares? This can be delayed tho.
Council notes
Anansi router example:
Beta Was this translation helpful? Give feedback.
All reactions