Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not execute success callback instead of throw error if bundle is already defined? #72

Closed
bolasblack opened this issue Jul 25, 2018 · 2 comments

Comments

@bolasblack
Copy link

bolasblack commented Jul 25, 2018

The code is here:

https://github.com/muicss/loadjs/blob/b1795cf94a3429619c3dfe947fcb303c6d4e6b65/src/loadjs.js#L217-L224

This behavior looks so weird to me.

Is there any reason for doing this?

@amorey
Copy link
Member

amorey commented Jul 25, 2018

That code path is reached if a user tries to define a new bundle using an old name. If you want to add a new success callback to a previously-defined bundle you can use the .ready() method:

// define bundle and add a success callback
loadjs(['/file1.js', 'file2.js'], 'mybundle', function() {
  /* success-callback-1 */
});

// add another success callback
loadjs.ready('mybundle', function() {
  /* success-callback-2 */
});

@bolasblack
Copy link
Author

bolasblack commented Jul 26, 2018

Got it :P

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants