MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.20.0 is available! For more information about this release, check out this topic.

    SOLVED Events (onHide, onShow)

    Development
    2
    3
    1286
    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
      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
      • yawns
        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
          Anhalter42 last edited by

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

          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 Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy