• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Notification between modules

Scheduled Pinned Locked Moved Solved Development
10 Posts 4 Posters 2.7k Views 4 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.
  • S Away
    sdetweil
    last edited by sdetweil Dec 27, 2018, 4:33 AM Dec 27, 2018, 4:32 AM

    technically, you are not supposed to update the dom until getDom() method time.
    you can update the data in the notificationReceived method, and then call updateDom() to indicate you have changes to present.

    this will cause getDom() to be called.

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    G 1 Reply Last reply Dec 27, 2018, 4:53 AM Reply Quote 1
    • G Offline
      grasshopper001 @sdetweil
      last edited by Dec 27, 2018, 4:53 AM

      @sdetweil but I did call updateDom() in ModuleB…

      1 Reply Last reply Reply Quote 0
      • G Offline
        grasshopper001
        last edited by Dec 27, 2018, 8:31 AM

        finally I solved this problem as @sdetweil told me: keep all coding of DOM within the getDom() function, initialize my data in start function, and update the data in the notificationReceived method.
        the updateDom() function is repeatedly called after receiving “DOM_OBJECT_CREATED” notification.

        S 1 Reply Last reply Dec 27, 2018, 1:06 PM Reply Quote 0
        • I Offline
          idoodler Module Developer @grasshopper001
          last edited by Dec 27, 2018, 9:13 AM

          @grasshopper001 You are in two different scopes. Try to add .bind(this) to your setInterval’s callback.

          Also do you see any errors on the browser side?

          • Open Chrome and navigate to your MagicMirror’s Webinterface
          • Open the Chrome Dev Tools via F12 (on Windows)
          • Keep an eye out for anything red in the console
          • Optional You can also directly debug your modules code in the dev tools.
          S G 2 Replies Last reply Dec 27, 2018, 9:39 AM Reply Quote 0
          • S Offline
            strawberry 3.141 Project Sponsor Module Developer @idoodler
            last edited by Dec 27, 2018, 9:39 AM

            @idoodler he’s using arrow functions =>, therefore he stays in the same scope.

            Please create a github issue if you need help, so I can keep track

            I 1 Reply Last reply Dec 27, 2018, 9:54 AM Reply Quote 1
            • I Offline
              idoodler Module Developer @strawberry 3.141
              last edited by Dec 27, 2018, 9:54 AM

              @strawberry-3-141 Thanks, again what learned:)

              1 Reply Last reply Reply Quote 1
              • S Away
                sdetweil @grasshopper001
                last edited by Dec 27, 2018, 1:06 PM

                @grasshopper001 nice work.

                One comment to think about. You should not call updateDom() if you do NOT have changed content to present

                This wastes cpu cycles, raising heat. And maybe preventing some other module from displaying properly.

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                G 1 Reply Last reply Dec 28, 2018, 3:34 AM Reply Quote 1
                • G Offline
                  grasshopper001 @sdetweil
                  last edited by Dec 28, 2018, 3:34 AM

                  @sdetweil Thanks! I’ve rewritten my code according to your comment.

                  1 Reply Last reply Reply Quote 0
                  • G Offline
                    grasshopper001 @idoodler
                    last edited by Dec 28, 2018, 3:37 AM

                    @idoodler thanks for the help.The console part in the dev tool does help a lot!

                    1 Reply Last reply Reply Quote 1
                    • 1 / 1
                    1 / 1
                    • First post
                      6/10
                      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