renderedtext / render_async

render_async lets you include pages asynchronously with AJAX
https://rubygems.org/gems/render_async/
MIT License
1.08k stars 75 forks source link

Feature idea: Render async with ActiveJob & ActionCable #111

Open mnort9 opened 4 years ago

mnort9 commented 4 years ago

Rendering with ActiveJob & ActionCable would allow for long performing background jobs to push view content when finished.

Rough Flow:

  1. Render async called in view, which also creates ActionCable client subscription
  2. Controller action immediately queues background job for processing
  3. When job completes, content is broadcasted to client
  4. Client inserts content into page from the subscription success callback

Use Case: We have some long running queries in our admin interface around reporting. Since this is internal, it's not that big of a deal that a response takes 10 seconds, especially since it's only used a few times a day. We'd rather focus dev optimization effort on the customer facing part of the application.

However, this request can cause timeouts for the rest of the application, especially if requests are simultaneous. Pushing the processing to the background and rendering when ready would allow it be truly non-blocking for other requests.

nikolalsvk commented 4 years ago

Hey, @mnort9! Thanks for submitting an issue, the idea sounds great. I was thinking of this some time ago myself but never wound up drafting a PR.

Let me know if this is something you'd like to participate in, I'd be more than glad to help!

Also, if others are interested in seeing this feature, react with 👍

feliperaul commented 4 years ago

This would be awesome, and it could use the new StimulusReflex