-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Refresh with event #129
Comments
Thanks a lot, @pedantic-git! It really is a pedantic description 😄 I will try to tackle this in the next batch of updates. |
Awesome! Looking forward to it! Let me know how I can help! |
Hey, @pedantic-git. I added support for dispatching an event with the name Let me know if this is something you were looking for. Also, let me know if there are some improvements we could make to it so it's even better. Cheers 🍻 |
@nikolalsvk Thanks for this! I haven't had a chance to test it in Stimulus because I implemented it in UJS and that implementation works - but I've replaced my hacky UJS view with one that raises the |
Awesome, @pedantic-git. I am glad you like it, feel free to share any improvement ideas, it was nice working with you. |
I'm leaving this issue here after a chat with @nikolalsvk on Discord yesterday.
While it's great that render_async allows the rendered partial to be 'refreshed' (i.e. fetched and rendered) on a periodic basis with polling, it would be great if instead it could be refreshed in response to a JavaScript event.
For example, in my case I have a form on the user settings page that updates the user's status in Mailchimp. Because it integrates with a 3rd-party API, I render it asynchronously so that any failures/performance issues don't affect the rest of the page. When the user submits the form (using JavaScript) I want the resulting JS event to then refresh the entire partial to show the new status.
I imagine the API would be something like:
(or maybe you could have a default event name like
refreshAsync
and use the API only to override that name or disable the behaviour).Then attach an event handler to the root element that refreshes every time it sees that event.
As an example of how to use it: inside my component, at the end of my form-handling code in JavaScript I could dispatch the event using standard JS. For example:
Let me know if any of the above is not clear and I'll be happy to explain further!
The text was updated successfully, but these errors were encountered: