[Feature request] selector support for useRecoilTransaction()
See original GitHub issueI have the following issue.
Let’s say I have atom A with value 1.
- In mouse event handler the recoil callback with setter is called to set A value to 2.
- setTimeout callback fires, which in turn contains the recoil callback call. the
snapshot
in it still contains the A value of 1. The result of first step is not yet applied.
My question. Can I force all of the updates of the recoil callback to be applied right after the callback exits. e.g explicitly force not to batch it into a single transaction with subsequent callback calls ?
So subsequent callback (step two described above) call can read back the written value of previous callback call.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
useRecoilTransaction_UNSTABLE(callback, deps) | Recoil
Dynamically updating an atom where we may not know at render-time which atom or selector we will want to update, so we can't...
Read more >Exploring Asynchronous Requests in Recoil - AppSignal Blog
In this post, I'll take a close look at asynchronous queries in Recoil. I'll show you what the library is capable of and...
Read more >Getting Started with React Recoil | by kelly woo - Bits and Pieces
deep dive in atom & selector of recoil.js. ... with selectors are a bit tricky, I didn't write it here but selector supports...
Read more >Is it possible to initialise atomFamily multiple values at once?
In the meantime, is the useRecoilTransaction() approach more performant for you ... Feature Request: Add support for npm pakages, 0, 2022-03-21, 2022-10-29.
Read more >pm
The take_snapshot() function creates a snapshot instance. 5. ... The API package defines the Java interfaces supported by the Asset Consumer OMAS.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is definitely a feature I am missing in Recoil right now. A large application will likely have the requirement to get and set various atoms and selectors in one reusable “transaction” (akin to a traditional reducer), and currently I’ve come across only really one way to achieve this, which is via vanilla React hooks. There are several problems using traditional hooks in this way:
useCallback
with all its dependencies (lots of boilerplate again)useRecoilTransaction
is a selector with a setter that does all the work. However, it needs an arbitrary getter which results in confusing and ugly patterns.It’s entirely possible I am going about this wrong of course - anyone else have a solution akin to
useRecoilTransaction
but with selectors?I’d also like to echo @yoavniran and others here from over a year ago; is there a roadmap to move Recoil transactions from UNSTABLE to a permanent feature including the use of selectors? Thanks to @drarmstr and the dev team for all your efforts!
EDIT: typos & grammar
Am I right to think that
useRecoilTransaction
would/should be the only way to write setters with multiple “set” calls? If so, its really missing the option to get from selectors (and not just atoms). Is there a release date we can expect this to become available? thanks!