Read the statement by Michael Teeuw here.
Timer on Module
-
@dsmtweaker it would be setInterval (this.GetVid,…)
-
@dsmtweaker also think the getVid routine return is wrong
-
@dsmtweaker
getDom() is not good position for your job. That function will be called at anytime when it is needed to redraw your module by MM, not by you. You don’t know when it will be executed on which condition.Instead direct calling getDom, use updateDom(). Whenever you call ‘this.updateDom()’, MM will execute your getDom() and redraw your module with result of getDom()
Then, with setInterval(), you can repeat updateDom as your wish.
Of course, setInterval and updateDom should move out of getDom. So to where?
start() isn’t good also. My suggestion is, to create function yourJob() and put setInterval and uodateDom into yourJob(). Then call it by notification - “DOM_OBJECT_CREATED”.
-
@sean So, should I be putting the updateDom in a function? Such as…
// Override dom generator. getDom: function() { var intervalID = window.setInterval(this.GetVid, 60000); var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop; function GetVid() { updateDom } }
-
@dsmtweaker
I’ve added in prior post. Sorry I’m typing on my phone. So I cannot write long… -
job: function() { setInterval(()=>{ this.updateDom() // this will execute your getDom() }, yourInterval) }, notificationReceived: function (noti, payload, sender) { if (noti == “DOM_OBJECT_CREATED”) this.job() }, getDom: function () { //making your video DOM here. }
-
@sean Sorry for being so new at this. And thank you for all of the help. I tried using your code.
get: function() {
setInterval(()=>{this.updateDom()}, 60000)
notificationRecieved: function (noti, payload, sender) {
if (noti = “DOM_OBJECT_CREATED”) this.job()}, getDom: function () var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop; },
});
But I get “Uncaught SyntaxError: Unexpected token (” from notificationRecieved: function (noti, payload, sender) {
-
@dsmtweaker you missed some of the job function
this.updateDom()}, yourInterval)
-
@sdetweil It is there in the get:function
get: function() {setInterval(()=>{this.updateDom()}, 60000) notificationRecieved: function (noti, payload, sender) { if (noti = "DOM_OBJECT_CREATED") this.job() }, getDom: fuction () var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop;
},});
-
@dsmtweaker i hate code posting on this forum…
note that
getDom: fuction () is spelled wrong
and also missing the open brace