MagicMirror Forum

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

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

    Troubleshooting
    2
    5
    568
    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.
    • lavolp3
      lavolp3 Module Developer last edited by

      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 Reply Quote 0
      • S
        sdetweil @lavolp3 last edited by

        @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

        Create a working config
        How to add modules

        lavolp3 1 Reply Last reply Reply Quote 0
        • lavolp3
          lavolp3 Module Developer @sdetweil last edited by

          @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 Reply Quote 0
          • S
            sdetweil @lavolp3 last edited by sdetweil

            @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

            Create a working config
            How to add modules

            1 Reply Last reply Reply Quote 0
            • S
              sdetweil @lavolp3 last edited by

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

              Sam

              Create a working config
              How to add modules

              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