• 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.3k 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.
  • S Offline
    sdetweil
    last edited by sdetweil May 17, 2018, 9:44 PM May 17, 2018, 7:32 PM

    what is the model being used for both module and helper?

    where and how do I declare variables? either global or instance? (not method variables)

    in a helper if I declare outside the NodeHelper.create(…), they are truely global, and other helpers will overwrite my variables if the names collide.

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    I 1 Reply Last reply May 18, 2018, 7:45 PM Reply Quote 0
    • 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
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        1/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