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

Add setup and reset lifecycle hooks + replace support #30

Merged
merged 8 commits into from
Jul 25, 2017

Conversation

offirgolan
Copy link
Owner

@offirgolan offirgolan commented Jul 22, 2017

  • Added setup lifecycle hook
  • Added reset lifecycle hook
  • Added support to declare replace from the QP map
  • Removed asserts for empty argument passed into new QueryParams(). This can allow anyone to take advantage of all the life cycle hooks even if they dont have QPs to declare.
  • Tests
  • Docs

With this PR we can actually eliminate the need for the route to declare any query params as well as handling data 🎉

@offirgolan offirgolan requested a review from poteto July 24, 2017 04:10
@offirgolan
Copy link
Owner Author

@poteto @ebryn this is ready for review 😄

@offirgolan offirgolan changed the title [WIP] Add setupController and resetController hooks Add setup and reset lifecycle hooks + replace support Jul 24, 2017
const {
keys
} = Object;

export function initialize(/* application */) {
Ember.Route.reopen({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't be reopening in an instance initializer.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@poteto what was the reason for switching over to an instance initializer?

integration: true,

beforeEach() {
Ember.Route = Ember.Route.extend();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad

@poteto
Copy link
Collaborator

poteto commented Jul 25, 2017

As discussed let's do a readme overhaul in a separate PR

// Overrides
event.shouldRefresh = false;

tryInvoke(controller, 'reset', [event, isExiting]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if we should even send a ParachuteEvent on resetController. Is there a scenario where the QPs change when the route resets? In the reset hook, the user can still access current QPs, reset QPs etc via the mixin. So it seems like we might be sending more than is necessary

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it for the sake of consistency. That way you have access to all the same data in setup, reset, and queryParamsDidChange.

@offirgolan offirgolan merged commit 063d958 into master Jul 25, 2017
@offirgolan offirgolan deleted the lifecycle-hooks branch July 25, 2017 16:41
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.

3 participants