user feedback for asynchronous tasks in rails
i have an action that executes a "possible" long running task. A possible, because it does a request to a remote server, and because of network latency, it can block the user interface and give a small delay to the user.
My question is not related with "how to send long tasks in background", but how to push a notification to the user. My idea, was that the user clicks the button, it fires a task in background, the web interface is unblocked, and the user can do whatever he wants and, when the task is done, he receives a flash message. I can do it with AJAX, polling the server, a specific action that gives me the status of my task, for example, but there is any pattern to do it event based? Kudos for answers with proof of concept or prototyp开发者_如何学运维es.
No proof of concept here, but you could use something like spawn or delayed_job to fire off your Rails task and unblock the interface, and then communicate back to the client with node.js or something similar. Depending on what you want to do, however, long-polling may be more practical than setting up more server software.
精彩评论