@idoodler thanks for the help.The console part in the dev tool does help a lot!
Read the statement by Michael Teeuw here.
Best posts made by grasshopper001
-
RE: Notification between modules
Latest posts made by grasshopper001
-
Italic font awesome
Did anyone tried font awesome in MagicMirror?
I found my fa-icons appear to be italic in MagicMirror. Could anyone help me with this strange italic icon problem?
My html in getDom function is like:<i id="fa-star" class="icon">& #xf0 05</i>
(I added some nonsense space so that the innerhtml would not be like )
-
RE: Notification between modules
@idoodler thanks for the help.The console part in the dev tool does help a lot!
-
RE: Notification between modules
@sdetweil Thanks! I’ve rewritten my code according to your comment.
-
RE: Notification between modules
finally I solved this problem as @sdetweil told me: keep all coding of DOM within the getDom() function, initialize my data in start function, and update the data in the notificationReceived method.
the updateDom() function is repeatedly called after receiving “DOM_OBJECT_CREATED” notification. -
RE: Notification between modules
@sdetweil but I did call updateDom() in ModuleB…
-
Notification between modules
I tried to have two modules sending notification to each other: ModuleA sending “TEST_NOTI” to ModuleB, and ModuleB shows the information of this notification on mirror.
I put ModuleA and ModuleB in different folders named by themselves.
My code in ModuleA is like:start:function(){ this.count=0; }, notificationReceived:function(notification,payload,sender){ switch(notification){ case "DOM_OBJECTS_CREATED": var timer=setInterval(()=>{ this.count++; this.sendNotification("TEST_NOTI",this.count); },1000) break; default: break; } },
My code in ModuleB is like:
getDom:function(){ var wrapper=document.createElement("p"); wrapper.className="test results"; wrapper.id="parent"; wrapper.innerHTML="test results: "; return wrapper; }, notificationReceived:function(notification,payload,sender){ var self=this; switch(notification){ case "DOM_OBJECTS_CREATED": setInterval(()=>{ this.updateDom(); },1000) break; case "TEST_NOTI": var parent=document.getElementById("parent"); var child=document.createElement("p"); child.id="test notification"; child.innerHTML="TEST_NOTI received"+payload; parent.appendChild(child); break; default: break; } },
I assume that ModuleB will show
test results: TEST_NOTI received [counting]
where [counting] counts from 1 to infinity.
However, the second line of my assumption only appears occasionally
. I could hardly find any regulation in its appearance.
Could anyone help me to figure out whether its a problem within my code or its a problem of the notification connection?
Are there any place to learn about the notification except the doc? -
RE: how and where should I use the hide&show function offered by MM?
Finally I deleted the node helper, it seems that MM functions does not work in node helper functions.
But the setTimeout function in notificationReceived function still does not work with “DOM_OBJECT_CREATED”. -
RE: how and where should I use the hide&show function offered by MM?
It seems that MM is not available?
I tried to write shutOtherModule function in node-helper, and MagicMirror told me thatReferenceError: MM is not defined
How could I get access to MM object? Why my MagicMirror responded me with a blank mirror when the function is called after receiving “DOM_OBJECT_CREATED” notification?
-
RE: how and where should I use the hide&show function offered by MM?
codes&question updated
setTimeout(shutOtherModule(),10000); function shutOtherModule(){ MM.getModules().exceptModule(this).enumerate(function(module){ module.hide(); }) }
question:
When I put the above codes in start function, the module never hides other modules.
When I put the above codes in notificationReceived function and let MagicMirror do the codes after receiving “DOM_OBJECT_CREATED” notification, It seems that the module shuts down all modules including itself, leaving me with a blank mirror. -
how and where should I use the hide&show function offered by MM?
I tried to hide all other modules except the current module, but it seems does not work. I put my codes to hide other modules inside the start function of the current module.
Module.register("MMM-hideOtherModules",{ defaults:{}, start:function(){ setTimeout("shutOtherModule",5000); function shutOtherModule(){ MM.getModules().exceptModule(this).enumerate(function(module){ module.hide(); }) } }, //not important functions }
Could anyone help me with a sample module to hide other modules? Are there any place to learn about the inner structure of inter-modules communication except the doc?