googlearchive / IMD

An AMD-compatible module registry for use with HTML Imports
73 stars 24 forks source link

New Feature: AsyncPromises (Alpha) #16

Open SMotaal opened 7 years ago

SMotaal commented 7 years ago

Using delegate methods for IMD's define and require (optional) to allow a module registry (basic) class to create and resolve promise chains for asynchronous dependency management. When a script is loaded out of order it will not fail because one of its dependencies was not previously loaded but instead a promise will be made that can then be resolved to pass dependencies when they are available for any deferred define calls.

Intent:

When managing large projects with many dependencies that are being developed independently, including script tags at the component level will require a lot of overhead to ensure the proper version of a dependency is used across multiple components. One solution is to load the scripts in the index.html file before loading dependencies, but having script tags inside the components that refer to different versions of the same dependency can lead to unpredictable outcomes.

AsyncPromises handle dependency management using promises, allowing for a centralized layer for added control that can be extended to fit the needs of large projects. The current implementation is only basic and should be extended for production use.

Note:

I'm using ES6 classes which might require transpilation for certain environments.

googlebot commented 7 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


SMotaal commented 7 years ago

I signed it!

googlebot commented 7 years ago

CLAs look good, thanks!