• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Realtime Parameters Parsing

Scheduled Pinned Locked Moved Troubleshooting
8 Posts 2 Posters 2.8k Views 2 Watching
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 Offline
    yours.mukul
    last edited by Sep 10, 2017, 7:05 PM

    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

    ? 1 Reply Last reply Sep 10, 2017, 7:30 PM Reply Quote 0
    • ? Offline
      A Former User @yours.mukul
      last edited by A Former User Sep 10, 2017, 7:33 PM Sep 10, 2017, 7:30 PM

      @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 Sep 11, 2017, 6:04 PM Reply Quote 0
      • Y Offline
        yours.mukul @Guest
        last edited by Sep 11, 2017, 6:04 PM

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

        ? 1 Reply Last reply Sep 11, 2017, 6:09 PM Reply Quote 0
        • ? Offline
          A Former User @yours.mukul
          last edited by A Former User Sep 11, 2017, 6:11 PM Sep 11, 2017, 6:09 PM

          @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 Sep 11, 2017, 6:15 PM Reply Quote 0
          • Y Offline
            yours.mukul @Guest
            last edited by Sep 11, 2017, 6:15 PM

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

            ? 1 Reply Last reply Sep 11, 2017, 6:40 PM Reply Quote 0
            • ? Offline
              A Former User @yours.mukul
              last edited by A Former User Sep 11, 2017, 6:44 PM Sep 11, 2017, 6:40 PM

              @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 Sep 11, 2017, 6:45 PM Reply Quote 0
              • Y Offline
                yours.mukul @Guest
                last edited by Sep 11, 2017, 6:45 PM

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

                ? 1 Reply Last reply Sep 11, 2017, 6:54 PM Reply Quote 0
                • ? Offline
                  A Former User @yours.mukul
                  last edited by Sep 11, 2017, 6:54 PM

                  @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
                  1 / 1
                  • First post
                    1/8
                    Last post
                  Enjoying MagicMirror? Please consider a donation!
                  MagicMirror created by Michael Teeuw.
                  Forum managed by Sam, technical setup by Karsten.
                  This forum is using NodeBB as its core | Contributors
                  Contact | Privacy Policy