Read the statement by Michael Teeuw here.
Trouble with Sending Notifcation on Module Start
-
I am trying to get a feature to work that depends on the clock module broadcasting a notification upon start up. I put a call to this.sendNotification() in the start() function in clock.js, but it doesn’t appear like it is being executed. Is there something subtle about the timing of modules being loaded so that the other modules is listening when the clock sends this notification?
Also, I know there was a post somewhere about logging. This is ten times harder than it should be because most/all of my log messages don’t seem to show up when I run: npm start dev.
Thanks so much for your help.
-
@raspberrypi9 all the modules aren’t ready yet
That is what the ALL_MODULES_STARTED and
DOM_OBJECTS_CREATED notifications are forAnd all the modules start() functions are called one module at a time, so UNLESS the module you WANT to talk to is BEFORE YOUR module in config.js. It’s not even loaded yet
-
So, net, don’t send to other modules til after ALL_MODULES_STARTED
-
Thank you!
-
@raspberrypi9 my pleasure,
And actually DOM_OBJECTS_CREATED means YOUR module’s content has been placed in the DOM the first time
And DOM_OBJECTS_UPDATED is each time after that
Because updateDom() is asynchronous nowIf you ever tried to document.getElementByID after getDom(),
but it returned null. Then you needed to wait for one of those notifications