-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add hooks support #46
Comments
@MagicCurlyHair I like the proposal! Would you be able to give it a try and implement it ? One thing that comes to my mind is that the dependency has to be a single file else we can not determine when it was really finished ( if it uses es modules ). We have already the same problem as showing loading template for webcomponents which use es modules, we hide loading once the initial file was loaded but it will then trigger further loadings as browser parses its imports... |
@tomastrajan |
@tomastrajan |
@MagicCurlyHair sure, I meant when using Of course developer can implement as precise solution for individual js files as necessary :) |
contains
How would you detect that everything was downloaded including files triggered by the |
Hi,
I have a use case where adding hooks support to
@angular-extensions/elements
would be beneficial. This idea is somewhat similar to #30, so maybe they could be implemented at the same time.Problem
Let's take an application with several Angular elements packaged as web components. Naturally, they may have several common dependencies that we may want to load only once per page (for example core Angular packages or
ngrx
). In order to improve UX and time to first meaningful paint, we postpone loading these dependencies until the components are requested by the current view.With the current API of
@angular-extensions/elements
I don't see a way this could be easily achieved.Proposal
Add hooks to
ElementConfig
:The library will execute
beforeLoad
hook before inserting script with the component's JS bundle. If the hook returns a Promise (which is necessary in this particular case), the library will wait for this Promise to resolve before proceeding with the request. If the Promise fails, the corresponding error component is shown instead.Do you think this API makes sense for
@angular-extensions/elements
?The text was updated successfully, but these errors were encountered: