Read the statement by Michael Teeuw here.
Realtime Parameters Parsing
-
@yours.mukul I recommend to build your own module from scratch for it or just fork original and modify it. It might be easier and the right way.
Of course, you could manipulate other module because javascript has incomplete capsulation. You can execute other module’s member function and access member variables, but that is not smart way, because the module was not developed for that purpose.(if could, the module would serve those kinds of methods or notification system)
So if you need some extra functionalities, first thing to do is requesting to original module developer. Second is to fork original source and add your needs, then use it privately or make pull-request to original. The last would be building your own module from scratch. -
@Sean can you please tell me a method to parse configuration after a module has been started ?
-
@yours.mukul
More detailed information is needed. Exactly what do you want? Your question is so ambiguous.
As I guess, You may want to change URL ofiFrame
module at runtime.
First, there are severaliFrame
related modules. I’ve searched them from google.(https://goo.gl/jLVXsE) So, which module did you intend? -
@Sean The
iFrame
is just an example I’m giving here. My question is for every module, like a youtube module or google maps module or any other module. Is it possible to change parameters of any module at runtime ? -
@yours.mukul
I can say just case-by-case. There is no common way to manipulate other modules except official notification mechanism.Every module works differently. Some modules are initialized in
.start()
with configuration values. In some reason, some modules are initialized whenDOM_OBJECTS_CREATED
notification received.(Yes, I usually use that.)So, what is your real intention? Just to get and change
module.config
? Yes. you can accessmodule.config
.MM.getModules().enumerate((m)=>{ console.log(m.name, m.config) })
Test it when modules are loaded.
However, just modifying that value doesn’t work as your wish. Modifying is available, but the result might not be something you want.
Every module uses configuration values by their own convenience. So, if you could success to change theurl value
ofMMM-SomeIFrameView
at some specific time, That doesn’t mean changing the view of that module automatically. Because that module wouldn’t use that value anymore after once used in.start()
. In that case, your modifying is just useless.Therefore, I just can say
case-by-case
. There is no common way for your wish. -
@Sean
what if i reinitialize the module after parsing the value or what if I just refresh the module after parsing the value ? -
@yours.mukul
Maybe you can do like this;MM.getModules().enumerate((m)=>{ m.config = YourNewConfig m.start() // Yes. It works! })
you can execute
.start()
of other module like above. But It could cause the serious problem for other modules. Maybeclock
or other simple modules could work well. But some modules might have huge complexity and not bullet-proofed. (no one has not imagined his module could be re-configurable.) Twice initilizing is not recommended.