ember-engines icon indicating copy to clipboard operation
ember-engines copied to clipboard

Wrong loading substate is entered.

Open kellyselden opened this issue 7 years ago • 9 comments

Given

Router.map(function() {
  this.mount('my-engine');
});

and app/templates/loading.hbs app/templates/my-engine-loading.hbs

Only loading.hbs renders while waiting for my-engine. Shouldn't it render my-engine-loading.hbs?

kellyselden avatar Jun 08 '17 22:06 kellyselden

wouldn't it be app/templates/my-engine/loading.hbs?

knownasilya avatar Jun 08 '17 23:06 knownasilya

@knownasilya Not according to https://guides.emberjs.com/v2.13.0/routing/loading-and-error-substates/

It's important to note that for slow-model itself, Ember will not try to find a slow-model.loading template

kellyselden avatar Jun 08 '17 23:06 kellyselden

I should also note that when I turn the this.mount into this.route, it loads the correct template app/templates/my-engine-loading.hbs.

kellyselden avatar Jun 08 '17 23:06 kellyselden

@kellyselden seems like a legit bug. The loading/error substates/routes have been a mess for a long time. We tried cleaning them up last year but looks like we missed this edge case.

I'd recommend adding a failing test here and (if you feel up to it) looking into fixing (which will probably be around here).

Even though the changes will be upstream, we can keep this issue for tracking.

trentmwillis avatar Jun 09 '17 04:06 trentmwillis

This would need to be application-loading as part of the engine and hoisted from the engine to it's host. It can't load asynchronously and this was an active design decision we made. (Don't know where the documentation for that decision is anymore.) It definitely does not live outside of the engine's namespace as you have described, @kellyselden.

Try it inside of the engine namespace to see if we fully accounted for it or didn't finish implementation.

(Obviously possible to revisit this decision, just trying to provide context.)

nathanhammond avatar Jun 09 '17 07:06 nathanhammond

I don't remember the original decision making process, but I believe it was wrong. A host application should be able to provide a custom loading substate for when an Engine is loading.

trentmwillis avatar Jun 09 '17 15:06 trentmwillis

I agree with @trentmwillis. It seems like it would make sense for an engine consumer to not depend on an engine to handle the loading substate, and to provide a "fallback" of sorts. It would also put an engine more in line with how routes work, which is a good thing IMO.

kellyselden avatar Jun 09 '17 21:06 kellyselden

I also ran into related issues/confusion on loading sub-states, but eventually got my engine working after ready @nathanhammond comment. Using application-loading.hbs within the engine, itself works. Although, following the guides, it seems you can have loading.hbs or application-loading.hbs, but loading.hbs does not work in an engine it seems.

Also,

A host application should be able to provide a custom loading sub-state for when an Engine is loading.

My first inclination was to ONLY have the engine provide its own loading states, but I could see both ways though. Is the goal to keep allowing engines to provide a loading sub-state, and provide a way for the host application to "override" the engine's sub-state, either automatically or through some config?

jbailey4 avatar Oct 18 '17 17:10 jbailey4

Just want to confirm whether this issue is fixed.

tigressbailey avatar Jun 10 '18 13:06 tigressbailey