• 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.

programming model

Scheduled Pinned Locked Moved Development
11 Posts 2 Posters 5.5k 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.
  • I Offline
    idoodler Module Developer @sdetweil
    last edited by May 18, 2018, 7:45 PM

    @sdetweil If you want class variables you can do the following:

    module.exports = NodeHelper.create({
    
        variable1: true,          // This is one way
    
        start: function() {
            this.variable2 = true // This is another way
    
           // Both variables can be accessed via this.VARIABLE_NAME
        }
     });
    
    1 Reply Last reply Reply Quote 0
    • S Offline
      sdetweil
      last edited by May 18, 2018, 7:52 PM

      thanks…

      strange syntax tho…

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      I 1 Reply Last reply May 18, 2018, 7:53 PM Reply Quote 0
      • I Offline
        idoodler Module Developer @sdetweil
        last edited by May 18, 2018, 7:53 PM

        @sdetweil Thats simply how to define a variable inside an object in node.js :grinning_face_with_smiling_eyes:

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil
          last edited by May 18, 2018, 7:54 PM

          i have a lot of code running in another node/angular mirror app and have never seen this syntax…

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          I 1 Reply Last reply May 18, 2018, 7:57 PM Reply Quote 0
          • I Offline
            idoodler Module Developer @sdetweil
            last edited by May 18, 2018, 7:57 PM

            @sdetweil Wait, I think I misunderstoodyour question.

            Do you want to have a class variable just in your node_helper.js, or do you want to share a variable between node_helper.js and your MMM-ModuleName.js file?

            1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil
              last edited by May 18, 2018, 8:00 PM

              not class variable (I got that now), but shared would solve a ton of problems.

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              I 1 Reply Last reply May 18, 2018, 9:18 PM Reply Quote 0
              • I Offline
                idoodler Module Developer @sdetweil
                last edited by May 18, 2018, 9:18 PM

                @sdetweil I solved this problem by using this.sendSocketNotification This allows me to communicate with the modules interface.

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil
                  last edited by May 18, 2018, 9:25 PM

                  yeh, but all this notification event handling really messes up the code i have which is all angular promise based.

                  I want to open my own browserwindow (show image), but u can’t do that in a module, only in a helper,
                  but then the window handle object needs to be stored inside the object which is managing the list of images for this ‘viewer’. that object is stored in the module… so, how do I transport the window handle object to the module… is the object valid in the other context (helper vs module).

                  see the topic ‘what can i do in a module’. (which u already have)

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  I 1 Reply Last reply May 18, 2018, 9:32 PM Reply Quote 0
                  • I Offline
                    idoodler Module Developer @sdetweil
                    last edited by May 18, 2018, 9:32 PM

                    @sdetweil I don’t think that. The helper is running on your Raspberry Pi, the module is running in every browser instance you open.

                    You need to coordinate your “show image event” from the helper and send out a notification to the module what image to show.

                    The ViewManagement must be in the module, the image downloading, handling must be in the helper.

                    Note: You only have one helper, but you can have multiple modules!

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil
                      last edited by May 18, 2018, 10:11 PM

                      thanks… the image is not shown in the dom, it is shown in a separate ‘browserwindow’, floating over the dom. i just loadUrl the image into the window, after creating and positioning it.
                      the mirror code doesn’t know the images are there

                      pictorial calendar reminders.

                      I have tested that the helper needs to do all this window mgmt

                      The scheduler module does scheduling (compare db data to calendar entries), start/stop viewer(s), and provide indirect services to load images depending on their source (file, dropbox, google drive, one drive).

                      The viewer module just walks thru a list of urls (getNext()) and opens a window hidden, loads image, hides old window, shows new window, deletes old window. (avoid dead window during load and, minimize screen flash)

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

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