Read the statement by Michael Teeuw here.
Except a module in getModules()
-
socketNotificationReceived: function(notification, payload) { var i,modules = MM.getModules(); if (notification === "BUTTON_PRESSED"){ this.sendNotification(notification, payload); for(i=0; imodules.length; i+=1){ if(modules[i].hidden == true){ modules[i].show(0); } else if(modules[i].hidden == false) { modules[i].hide(0); } } }
I want to show/hide all the modules except the **hello world ** module. Please help me out with that.
Note: I was unable to write less than sign in the for loop while writing this reply, I think its a bug, in this forum, whenever I write less than, all the text after it is is ignored.
-
@yours.mukul i can’t test it right now. what error do you get?
try the example from the docs
socketNotificationReceived: function(notification, payload) { if (notification === "BUTTON_PRESSED"){ MM.getModules().exceptModule(helloworld).enumerate(function(module) { module.hide(1000, function() { //Module hidden. }); }); } }
-
@strawberry-3.141 how to iterate over the modules array ?
I want to show/hide all modules except the “helloworld”. -
MM.getModules().enumerate((module)=>{ if(module.name !== "helloworld") { module.hide() } })
This is written by hand, so there might be error, but you can understand how it goes.
-
@yours.mukul enumerate will iterate over the array and will execute the function you specify for each module in the array
-
@strawberry-3.141 Well your code didn’t hide any of modules
-
@yours.mukul do you get any errors?
-
@yours.mukul
In.exceptModule(someModule)
,someModule
should be an instance of module object. It means you should get the object first before enumerating.
Usually, you can get module object instance with notification. In other way, you should enumerate all modules first, filter them by name(or any other condition), after then you can use those objects for.exceptModule()
as parameter.So I think you’d better examine other modules how they handle this. Not so difficult.
-
@strawberry-3.141 No there were no errors but I didn’t hide my modules