Change in UI triggered from timer

Change in UI triggered from timer



Question from a newbie, so best practice advice is very welcome.

In the application I'm working on, I have an action in a timer that is triggered when the user clicks a button. The action in the timer can run for several minutes before it completes, so I would want to provide some feedback to the user regarding the status of calculation, for example to prevent them from clicking the button again before the calculation is over. 

On higher level I planned to have some sort of event listener in the UI thread, so that for example when the action in the timer is ending, it would emit an event that would trigger an AJAX refresh in the UI. I went to try the events module, however after a few random trials I'm not sure I correctly understand how it works.

So to sum it up - if I have an action running in a timer that I would want to interact with the UI - what would be a good approach?

Thank you in advance for any advice!

Hi Dmitry,

The timer runs in a separate session on the server and has no connection with your webbrowser. This makes it impossible to interact directly with your webbrowser.

There are two solutions.

1. Add a javascrip timer on the client side that polls the timer-progress (via an entity in the database, for instance). When the entity is updated, the javascript could execute a refresh of a (part of a ) screen and then your data is updated.

2. Use a 3rd party tool (Paid service) to implement websockets into your application. I've created a forge component that implements This way you can push information from your timer directly to subscribed clients. If all your clients subscribe to a unique channel, you can update specific clients.

Kind regards,

Remco Dekkinga