taoeffect / vue-script2

Standardized, designer-friendly <script> behavior for your Single Page App
171 stars 15 forks source link

setting loading promise on request (not on load) to avoid duplicate l… #29

Closed vgavro closed 5 years ago

vgavro commented 5 years ago

closes #12 Setting loading promise on request (not on load) to avoid duplicate loadings before load were finished See https://github.com/taoeffect/vue-script2/issues/12#issuecomment-405803795

PROPOSAL (backward incompatible): rename Script2.loaded to Script2.load because we also store promises which is still in progress. What do you think?

Also:

  1. fixed verbose async=false (will act as async=true previously because of isUndefined check)
  2. added events on script load and script error for usage like this:
    <template>
    <script2 src="myscript.js" @load="loaded" />
    <template>
    <script>
    export default {
    methods: {
       loaded () {
          window.myscriptModule.youVeGotTheIdea()
       }
    }
    }
    </script>
taoeffect commented 5 years ago

@vgavro Thank you for the pull request! I will need some time before I can get to reviewing it however, please understand. However it is now on my TODO list and is very much appreciated!

g3rd commented 5 years ago

@taoeffect has this moved up on your TODO list?

taoeffect commented 5 years ago

@g3rd Yes, thank you for the reminder! There are still some items that require my immediate attention first. If this is an urgent issue for you, I recommend simply creating a file in your project that has all of the code from this project copy/pasted into it, along with the changes here.

This is not a project that I expect to have a rapid development cycle, so you won't be missing much, and you can always check back from time to time to see if these changes were merged back in. (Plus, you'll be slightly more secure because you won't be relying on npm! 😄)

taoeffect commented 5 years ago

I've merged this and will fix the issues I found in it. Thank you for your PR and my apologies for the time it's taken me to get back to this!

taoeffect commented 5 years ago

Published 2.1.0! Note that load event was renamed to loaded.