Seems like plugins almost always have some sort of setup to go through when they’re first used. Really, they’d want to just run that code when first imported. But presumably there is no way creators can do that, currently. As it’s such a common use-case, having something like this built-in for plugins would be useful, I think.

  • @wthit56OP
    link
    English
    14 months ago

    I see. So is that only run once, to store it in the local list-variable by the user? That’s an interesting way to do it. And lets us add properties… but that would only work after it’s accessed? Or could the user do [plugin.prop] and it would work as the first code block?

    • @perchanceM
      link
      English
      2
      edit-2
      4 months ago

      So is that only run once

      Ah, no, good catch - that would have re-run every time. I’ve updated the code above to fix that.

      could the user do [plugin.prop]

      Yep, $output will resolve to window.__fooPluginFn which is the foo function, so if you’ve got fooPlugin={import:foo-plugin} then you can write fooPlugin.prop immediately and it’ll work fine.

      • @wthit56OP
        link
        English
        14 months ago

        Cool 👍

        Basically, an $onload function to be called like that automatically would be all it takes, I think. I don’t think I’ve seen the actual importing code, but presumably it injects stuff into the top-level page or something. At which point it could call the onload maybe?