Read the statement by Michael Teeuw here.
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? -
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()
:DTopic can be deleted if desired.