Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.15.0 is available! For more information about this release, check out this topic.

    Realtime Parameters Parsing

    Troubleshooting
    2
    8
    2056
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yours.mukul last edited by

      How to parse parameters to a module in realtime?
      For e.g. I want to parse the url to iFrame module from a website, and I need it to change go to the current url parsed without restarting the whole MagicMirror

      Sean 1 Reply Last reply Reply Quote 0
      • Sean
        Sean Module Developer @yours.mukul last edited by Sean

        @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.

        Y 1 Reply Last reply Reply Quote 0
        • Y
          yours.mukul @Sean last edited by

          @Sean can you please tell me a method to parse configuration after a module has been started ?

          Sean 1 Reply Last reply Reply Quote 0
          • Sean
            Sean Module Developer @yours.mukul last edited by Sean

            @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 of iFrame module at runtime.
            First, there are several iFrame related modules. I’ve searched them from google.(https://goo.gl/jLVXsE) So, which module did you intend?

            Y 1 Reply Last reply Reply Quote 0
            • Y
              yours.mukul @Sean last edited by

              @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 ?

              Sean 1 Reply Last reply Reply Quote 0
              • Sean
                Sean Module Developer @yours.mukul last edited by Sean

                @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 when DOM_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 access module.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 the url value of MMM-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.

                Y 1 Reply Last reply Reply Quote 0
                • Y
                  yours.mukul @Sean last edited by

                  @Sean
                  what if i reinitialize the module after parsing the value or what if I just refresh the module after parsing the value ?

                  Sean 1 Reply Last reply Reply Quote 0
                  • Sean
                    Sean Module Developer @yours.mukul last edited by

                    @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. Maybe clock 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.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Enjoying MagicMirror? Please consider a donation!
                    MagicMirror created by Michael Teeuw.
                    Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                    This forum is using NodeBB as its core | Contributors
                    Contact | Privacy Policy