-
Notifications
You must be signed in to change notification settings - Fork 27
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 template helper for loading a bundle. #56
Comments
I had always figured that this helper would live in the I can't imagine the helper being very useful outside of |
I think my thought was that this addon and its main service is what is responsible for loading bundles, so it is the thing that should provide the helper. Though it's helper should likely be Am I on the wrong track? |
Wouldn't the helper also need to actually register the engine after it had finished downloading the bundle? |
Hmm. What do you mean? Loading the bundle would mean that the modules that the Note: I haven't ran the code I pasted above in the description. So perhaps I'm missing something obvious... |
Its entirely possible that I am actually missing something obvious, but I would have thought that the helper would need to register the engine with the application after successfully downloading its bundle. So essentially, the call to // Load un-registered engine
this.get("assetLoader").loadBundle(engineName).then(() => {
// Get engine
const engine = window.require(`${engineName}/engine`).default;
// Register engine with application
owner.register(`engine:${engineName}`, engine);
// Update this._engineName
this._engineName = engineName;
// Trigger recompution of helper
this.recompute();
}); |
Ya, I just think that manual registration shouldn't be needed. Once the bundle is loaded, the |
Ah I see, if thats the case and it works then keeping the helper in the |
Overall, this seems like a reasonable addition to this addon.
Agreed. Either
This is correct, and essentially what we do for routable engines. |
Yep, this sounds good. |
The most recent Ember.js times newsletter had a reference to this, that reminded me about this addon I once wrote: I guess this is not really relevant, since it uses a component instead of a template helper, but maybe you still find it useful. ✌️ |
@buschtoens your addon covers an important usecase - loading state. Probably should also cover error state? How would that be handled in the |
Glad that you like it :) In fact it does cover error states as well. I've updated the docs to reflect that. {{#lazy-mount engineName model=optionalDataForTheEngine as |engine|}}
{{#if engine.isLoading}}
🕑 The engine is loading...
{{else if engine.error}}
😨 There was an error loading the engine:
<code>{{engine.error}}</code>
{{/if}}
{{/lazy-mount}} |
@rwjblue @dgeb @stefanpenner what you think about make ember-lazy-mount as our solution to lazy loading route-less engines? makes sense when looking at engines RFC |
I know this might come up, so I'll address it right away: I have no problem with stripping out ember-concurrency(-decorators) and ember-decorators to reduce the bundle size for consumers that don't use these addons. |
yup @buschtoens and as asset-loader was written in ES6, we would have to remove the typescript as well. |
I've defactored ember-lazy-mount in buschtoens/ember-lazy-mount#4 to not use any dependencies except babel and htmlbars in order to decrease bundle size and also reverted back to the Ember Object Model, to make it possible to merge this code into |
Now that we know that Lazy Loading on ember-engines will work more friendly replacing what you think guys? |
(: >>> [🥇 UP 🥇] <<< :) |
Someone just needs to do the work 🤷♂️ |
thanks @rwjblue @buschtoens can you open a pull request on ember-engines adding your solution in It's your merit buddy! |
A template helper like this would allow folks to use lazy routeless engines with a nice(ish) syntax:
Example implementation (thanks to @mike183):
The text was updated successfully, but these errors were encountered: