Skip to content

Add onRouteStart option#8

Merged
mjc1283 merged 3 commits into
optimizely:masterfrom
mjc1283:add-on-route-start
Jan 18, 2017
Merged

Add onRouteStart option#8
mjc1283 merged 3 commits into
optimizely:masterfrom
mjc1283:add-on-route-start

Conversation

@mjc1283
Copy link
Copy Markdown

@mjc1283 mjc1283 commented Jan 17, 2017

@jordangarcia This adds the onRouteStart option.

Comment thread src/Router.js Outdated
this.__currentCanonicalPath = canonicalPath

if (this.onRouteStart && mode !== 'replace') {
this.onRouteStart();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it'd be good to supply some data to this function. Like the fromPath and make this threads through properly with redirects, as well as the startTime.

Thoughts?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yea, good point, I'll pass fromPath and startTime. Could you clarify what you meant about redirects?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Current canonical path might also be helpful for generalized onRouteStart functions. Would ctx be reasonable to be passed in as well?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah if we have Route A redirecting to Route B:

  • Route A start (should call onStart)
  • Route A redirect
  • Route A end (never called)
  • Route B start (should not call onStart)
  • Route B end (should call onEnd)

Copy link
Copy Markdown

@jordangarcia jordangarcia left a comment

Choose a reason for hiding this comment

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

LGTM

@mjc1283 mjc1283 merged commit 6864b2a into optimizely:master Jan 18, 2017
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