[Question] How to implement "click on a button then run an async action" in an elegant way?
See original GitHub issueI see the examples of async actions are about "running async actions when rendering a component, e.g. https://lostpebble.github.io/pullstate/docs/async-actions-creating
Now I have a different case: In a component, there is a button, when I click on it, it will run some async actions, and rendering different content base on the result of the async action.
I couldn’t find an elegant way to implement it, hope to have your help, thanks!
This is a small demo: https://github.com/freewind-demos/typescript-react-pullstate-async-actions-demo
The RemoteHello1
there is what I want to do (in traditional way), and the RemoteHello2
is what I want to use pullstate’s async actions but failed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
c# - Calling async method on button click - Stack Overflow
I've added async to my button click event handler and am await ing the async task but the async task is still running...
Read more >Asynchronous JavaScript - Learn web development | MDN
In this module, we take a look at asynchronous JavaScript, why it is important, and how it can be used to effectively handle...
Read more >Getting Started With Async Features in Python
This step-by-step tutorial gives you the tools you need to start making asynchronous programming techniques a part of your repertoire.
Read more >Using async-await feature in Angular | by Balram Chavan
In Angular application, we can use Rx.js to leverage power of Observables, Subject, BehaviorSubject etc for writing asynchronous code in elegant way.
Read more >Introduction to Cypress - Cypress Documentation
But the rule of thumb is simple: If you perform an action, like navigating the page, clicking a button or scrolling the viewport,...
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
@freewind , I just updated the project with the new changes I added.
It was actually very simple to add, don’t know what I hadn’t done it yet. Also made creating simple async actions easier, by just passing in a promise directly.
Thanks, the code is really nice and clean, thanks!