Events (onHide, onShow)



  • I’ve looked through the Module Development Documentation at https://github.com/MichMich/MagicMirror/tree/master/modules but couldn’t find anything about (handling of) events. In particular, I’m interested in reacting to the events when the module is shown or hidden, for example because of some other module calling .show() and .hide() on it. onShow for example could be useful to update the content of the module. If there are no event handlers to override, I’m only left with setting an update-interval in the start() method. This doesn’t look right for me…
    Do I miss something or is there a workaround for updating content on show?


  • Moderator

    This is shown in the readme:

    ####suspend() When a module is hidden (using the module.hide() method), the suspend() method will be called. By subclassing this method you can perform tasks like halting the update timers.

    ####resume() When a module will be shown after it was previously hidden (using the module.show() method), the resume() method will be called. By subclassing this method you can perform tasks restarting the update timers.


    Just add these functions to your module and do whatever you want to do



  • Ooops, my bad. Sorry for the silly question. Was so focused on the event-derived names onX() :D

    Topic can be deleted if desired.


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.