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.

    Module Update Question

    Scheduled Pinned Locked Moved Development
    7 Posts 2 Posters 714 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.
    • O Offline
      oldrocker
      last edited by

      I apologize in advance for the ignorance.

      When building a module, how do I periodically update a variable? For example, let’s say I have a variable that is an array or list of files found on a share. I have to fetch the list on start, how do I tell it to do it again in 10 minutes in case there has been a change?

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @oldrocker
        last edited by

        @oldrocker In JavaScript there are two timing functions

        setTimeout
        and
        setInterval

        both take a function to call
        and numbers of milliseconds before calling the function

        timeout calls once
        interval calls over and over

        each returns an if that can be used to cancel the time function

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        O 2 Replies Last reply Reply Quote 0
        • O Offline
          oldrocker @sdetweil
          last edited by

          @sdetweil

          Ok, that helps a little. I’ll try some things with setInterval and come back again when I’m stuck. I see a lot of examples where updateDom is included in the setInterval. That just updates the config if necessary, correct?

          S 1 Reply Last reply Reply Quote 0
          • O Offline
            oldrocker @sdetweil
            last edited by

            @sdetweil I did it.

            Thanks for the help!

            1 Reply Last reply Reply Quote 1
            • S Offline
              sdetweil @oldrocker
              last edited by

              @oldrocker the call to updateDom() tells MM runtime that your module has new/updated content, and the MM runtime will call your getDom() method to get that ‘new’ content to replace what is already displayed.

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              O 1 Reply Last reply Reply Quote 0
              • O Offline
                oldrocker @sdetweil
                last edited by

                @sdetweil If I understand you correctly, the call to the Dom is for the visual content update and not necessary after updating data the running module relies on unless that data is to be immediately displayed.

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @oldrocker
                  last edited by

                  @oldrocker correct,… only for visual content change… MM doesn’t know anything else the modules does…

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • 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