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

[BUGFIX beta] Check that handler exists before triggering event #14087

Merged
merged 1 commit into from
Aug 19, 2016

Conversation

trentmwillis
Copy link
Member

This is necessary for lazily-loaded routes where the handler is not
available synchronously. This includes events like loading and
queryParamsDidChange which trigger synchronously after starting a
transition, in those cases we should by-pass handlers that are not
yet loaded.

cc/ @rwjblue @nathanhammond @dgeb

Note: I feel like I should add a test for this, but I feel like it makes more
sense to just test this in the ember-engines repo, since this code path is
impossible to hit normally.

@dgeb
Copy link
Member

dgeb commented Aug 18, 2016

LGTM. I think I'm fine merging without an additional test.

@dgeb
Copy link
Member

dgeb commented Aug 18, 2016

@trentmwillis could you please prefix the commit message with [BUGFIX beta] ?

@nathanhammond
Copy link
Member

The other approach we considered was a promise chain to guarantee that the handler was already loaded, but that was breaking everything in Ember and doesn't actually change the behavior here.

@trentmwillis trentmwillis changed the title Check that handler exists before triggering event [BUGFIX beta] Check that handler exists before triggering event Aug 18, 2016
@trentmwillis
Copy link
Member Author

@dgeb updated. I'm always unsure of what to prefix my commits with.

@krisselden
Copy link
Contributor

@dgeb I have doubts about this not being tested.

@dgeb
Copy link
Member

dgeb commented Aug 18, 2016

@krisselden That's fair. Let's hold off on merging until we can figure out the best way to test this.

This is necessary for lazily-loaded routes where the handler is not
available synchronously. This includes events like loading and
queryParamsDidChange which trigger synchronously after starting a
transition, in those cases we should by-pass handlers that are not
yet loaded.
@trentmwillis
Copy link
Member Author

Added two unit tests, let me know if you think more is needed. Opted for unit tests since the triggerEvent function is just an implementation of a hook from Router.js.

@rwjblue
Copy link
Member

rwjblue commented Aug 19, 2016

These tests seem good for the changes being made here.

I would like to make sure that we get at least one higher level acceptance style test that emulates what we are actually doing in ember-engines WRT to getHandler returning a promise. That doesn't need to block this PR per-se, but it seems fairly important to help avoid accidental regressions here...

@trentmwillis
Copy link
Member Author

@rwjblue I agree. Unfortunately, having getHandler return a Promise doesn't work without also modifying the default query params behavior, which is something I don't think we want to upstream yet since we haven't quite tested it out in the real world.

The only reason this PR is happening right now is because it seemed to make more sense than trying to monkeypatch it into the addon.

@rwjblue
Copy link
Member

rwjblue commented Aug 19, 2016

@trentmwillis - Would you mind making a followup issue here to add an acceptance test for getHandler returning a promise?

@trentmwillis
Copy link
Member Author

Opened an issue to follow up.

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

Successfully merging this pull request may close these issues.

5 participants