Windy Community
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    • Register
    • Login

    Windy Integration with React: Seeking Help with Plugin Initialization

    Developers
    1
    3
    830
    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.
    • Στάθης ΣταθόπουλοςΣ
      Στάθης Σταθόπουλος
      last edited by

      Hello there,

      After spending several hours trying to add Windy to a React project, I managed to hack my way into React-ifying Windy and got it to work. I’m planning on releasing the library once it's ready. However, I’ve hit a snag that I could really use some help with.

      The Issue:
      I can't seem to figure out where the @plugin-menu plugin is initialized so that I can reset it properly. The problem arises when the component unmounts and mounts again. Without resetting, I encounter an error when the plugin tries to reinitialize. I've found and reset some global variables (like window.W) that were causing issues, but I can't locate where the plugins are initialized.

      The Error:
      When I remount the object multiple times and try to open the menu, I get the same error as many times as I’ve remounted the map. This suggests that some data is stored every time the plugin is initialized—perhaps in a callback function? I’m considering downloading Chromium to dive deeper, but it’s quite heavy, so I wanted to check here first.

      I also downloaded the library and slowly and painfully de-obfuscating to maybe understand what it does with the plugins after all the variables are a little more readable.

      What I Need:
      Does anyone know a hacky way to reset the plugin? Any insights would save me a ton of time and effort. Regardless, I need to figure this out for the project I'm working on.

      Thanks in advance for any help!

      Στάθης ΣταθόπουλοςΣ 1 Reply Last reply Reply Quote 0
      • Στάθης ΣταθόπουλοςΣ
        Στάθης Σταθόπουλος @Στάθης Σταθόπουλος
        last edited by

        @Στάθης-Σταθόπουλος After de-obfuscating around 4000 lines of the 15000 I realized the problem is double event handles that are left over from the first initialization and even though I clean things after an un-mount the event listeners are still there and for example on menu click the fetch the new W.define and reload the script. I will keep this post updated when I figure it out. Maybe write a script for the rest of the people struggling with it.

        Στάθης ΣταθόπουλοςΣ 1 Reply Last reply Reply Quote 0
        • Στάθης ΣταθόπουλοςΣ
          Στάθης Σταθόπουλος @Στάθης Σταθόπουλος
          last edited by

          @Στάθης-Σταθόπουλος I finally found it. The ClickHandler module adds a global event on click to bubble and get picked up by the menu with data-do="rqstOpen,menu" for example and anything that may have events. When you unmount the component this event handler sticks and on remount it adds again a second time which breaks things because when you loadScript from @plugins/menu it re-defines it causing an error. I will make a public script real soon with the code to integrade windy with React unofficially. 15 hours of de obfuscating paid off :P

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
          NodeBB & contributors, OSM & contributors, HERE maps
          Terms of Use     Privacy Policy