xstate-fetcher: advanced fetching and caching for Xstate! #3537
mohannad-s-awad
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
xstate-fetcher
Hello folks. I am proud to share with you an alpha version of
xstate-fetcher
. It is a library inspired byreact-query
(created by the pioneer @tannerlinsley) for managing the complex asynchronous state of queries/mutations (called “fetchers”) usingxstate
with a global key-based cache.https://www.npmjs.com/package/xstate-fetcher
https://github.com/mohannad-s-awad/xstate-fetcher
Here is a demo example:
Key features (not a comprehensive list):
react-query
's where, for example, mutations are usually responsible to synchronize/invalidate other queries, but this approach will also be possible inxstate-fetcher
.react-query
.Coming features (not a final list):
Open design/usage questions for your valuable opinions please:
parent
property to interceptsendParent
,respond
, andescalate
actions then forward them to the invoking machine as part of the proxying logic. Is there a better approach?xstate
machine too? How am I supposed to handle/simplify synchronous calls/returns (mostly read-only computations)?xstate-fetcher
, for example, with UI component machines? Should one expose the fetcher interpreters to the view layer (e.g. Vue components) or should one encapsulate/hide them inside the invoking machines? With the second option, we need to map fetchers’ transitions/events to invoking machines’ events, which introduces some verbosity…Let me know please of what you think to develop this library further, or even change the whole approach if necessary. I have other questions regarding your newly recommended option
predictableActionArguments
and how to prepare for v5 migration…I am also planning to write an article about my experience developing
xstate-fetcher
usingxstate
. Where do you suggest a good place to publish my (first) article?Thank you all!
Mohannad
Beta Was this translation helpful? Give feedback.
All reactions