Read the statement by Michael Teeuw here.
updateDom, getTemplateData, getDom, start etc: What function is called when?
-
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 thenpm start dev
mode. 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? -
@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
getHeadersuspend and/or resume
-
@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…
-
@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()
-
@lavolp3 I also do not see any modules called twice.