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

updateDom, getTemplateData, getDom, start etc: What function is called when?

Scheduled Pinned Locked Moved Unsolved Troubleshooting
5 Posts 2 Posters 1.2k 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.
  • L Offline
    lavolp3 Module Developer
    last edited by Sep 11, 2019, 10:36 PM

    I really need to get some sleep, but before I’d like to place a question.

    Considering I have a module with a .njk template running, I do not understand what function/procedure is called at which point.
    I guess there could be some flowchart to visualize. However, I am not sure, e.g. at which points exactly “getTemplateData” is called.
    In my module it seems to be called right at the beginning although I have not invoked any getDom or updateDom yet (at least I don’t now of any…).
    Hope the problem is understood and happy for any insight.

    Also I have recognized that for some modules the start process is called twice and any setTimeout cycle as well.
    This at least counts for the npm start devmode. So you can have e.g a 10 minute cycle calling an api. This is for several modules called twice in the beginning. Is this linked to the two “sockets” being used for the monitor and for an external browser?

    How to troubleshoot modules
    MMM-soccer v2, MMM-AVStock

    S 2 Replies Last reply Sep 12, 2019, 1:53 PM Reply Quote 0
    • S Offline
      sdetweil @lavolp3
      last edited by Sep 12, 2019, 1:53 PM

      @lavolp3 looking thru the code in MagicMirror/js

      it looks like

      see loader.js, module.js, main.js

      module function calls in order

      init
      loadScripts
      loadStyles
      loadTranslations
      start
      getDom
      /* getDom() for html
      * This method generates the dom which needs to be displayed. This method is called by the Magic Mirror core.
      * This method can to be subclassed if the module wants to display info on the mirror.
      * Alternatively, the getTemplate method could be subclassed. for njk*/
      which calls
      getTemplate
      getTemplateData
      getHeader

      suspend and/or resume

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      L 1 Reply Last reply Sep 12, 2019, 3:26 PM Reply Quote 0
      • L Offline
        lavolp3 Module Developer @sdetweil
        last edited by Sep 12, 2019, 3:26 PM

        @sdetweil
        Thanks Sam!
        As for the getDom() method: Is this being called separately for every module or called for all modules when one module requests it?

        I see I have to dig deeper into the MM core code…

        How to troubleshoot modules
        MMM-soccer v2, MMM-AVStock

        S 1 Reply Last reply Sep 12, 2019, 4:06 PM Reply Quote 0
        • S Offline
          sdetweil @lavolp3
          last edited by sdetweil Sep 12, 2019, 4:43 PM Sep 12, 2019, 4:06 PM

          @lavolp3 separately for each module, after the first as part of startup, when it loops thru all the active declared modules to get their initial content.

          Technically it calls updateDom(), which then schedules the call to getDom()

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @lavolp3
            last edited by Sep 12, 2019, 4:26 PM

            @lavolp3 I also do not see any modules called twice.

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              3/5
              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