MagicMirror Forum

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

    module.js

    Bug Hunt
    2
    7
    267
    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.
    • H
      hango last edited by

      This post is deleted!
      S 1 Reply Last reply Reply Quote 0
      • S
        sdetweil @hango last edited by sdetweil

        @hango no… the MM functions locate modules

        then u have the module object and call hide on it
        from my SleepWake module

        MM.getModules().enumerate((module) => {
        				// if the module is already hidden
        				if(module.hidden==true)
        					// save it for wake up
        					{self.previously_hidden.push(module.identifier);}
        				else
        					// hide this module
        					{module.hide(1000);}
        			});
        

        https://docs.magicmirror.builders/development/helper-methods.html#module-selection

        Sam

        Create a working config
        How to add modules

        1 Reply Last reply Reply Quote 0
        • H
          hango last edited by hango

          This post is deleted!
          S 1 Reply Last reply Reply Quote 0
          • S
            sdetweil @hango last edited by

            @hango from main.js

            var showModule = function (module, speed, callback, options) {
            var hideModule = function (module, speed, callback, options) {
            

            Sam

            Create a working config
            How to add modules

            1 Reply Last reply Reply Quote 0
            • H
              hango last edited by

              This post is deleted!
              S 1 Reply Last reply Reply Quote 0
              • S
                sdetweil @hango last edited by sdetweil

                @hango before the call to hideModule
                there is a variable self set
                self is used to avoid the ambiguity of ‘this’, as inside callbacks ‘this’ can point to the caller, NOT the context where it was intended.

                	var self = this;     < ----- self is initialized to the current 'this' context
                	MM.hideModule(
                		self,              < -------------- should be 'this' ?
                		speed,
                

                so its the same
                and in the call there is a required function (the callback), in this case created inline

                		function () {
                			self.suspend();   // < --- make sure to use the right module context when this function is called
                                                                  // the compiler remembers that self was defined above 
                			callback();         // call the routine defined as callback
                		},
                

                Sam

                Create a working config
                How to add modules

                1 Reply Last reply Reply Quote 0
                • H
                  hango last edited by hango

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