MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Events (onHide, onShow)

    Scheduled Pinned Locked Moved Solved Development
    3 Posts 2 Posters 1.6k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Anhalter42
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • yawnsY Offline
        yawns Moderator
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • A Offline
          Anhalter42
          last edited by

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

          Topic can be deleted if desired.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy