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

Navigation lifecycle events #23

Closed
vlukashov opened this issue Apr 25, 2018 · 0 comments
Closed

Navigation lifecycle events #23

vlukashov opened this issue Apr 25, 2018 · 0 comments
Assignees
Milestone

Comments

@vlukashov
Copy link
Contributor

vlukashov commented Apr 25, 2018

As a developer I want to define handlers for navigation lifecycle events for a route component:

  • before a navigation to the component
  • before a navigation away from the component

DoD:

  • If a route component has an onBeforeEnter method, this method is called (during the resolve pass) every time before a navigation to the component happens.
  • If the onBeforeEnter method returns something (not null nor undefined), that return value is used as a resolve pass result for the component (instead of the component itself).
  • If a route component has an onBeforeLeave method, this method is called (during the resolve pass) every time before a navigation to the component happens.
  • If the onBeforeLeave method returns something (not null nor undefined), the resolve pass ends before actually navigating to where it was going to, and that return value is used as the resolve pass result.
  • (no demos are in scope for this story because the lifecycle callbacks are demoed in the issues Dynamic redirects #24 and Preventing transitions #25)

The common DoD applies.

@vlukashov vlukashov modified the milestone: 1.0.0 Apr 25, 2018
@vlukashov vlukashov added this to the M2 milestone May 14, 2018
@vlukashov vlukashov modified the milestones: M2, M3 May 22, 2018
@SomeoneToIgnore SomeoneToIgnore self-assigned this May 30, 2018
vlukashov pushed a commit that referenced this issue Jun 6, 2018
…in. (#140)

preparations for #23

---

* Provide `context.cancel()` method for inactivating the resolution chain.

* Merge branch 'master' into kb/context-cancel
vlukashov pushed a commit that referenced this issue Jun 6, 2018
…on. (#138)

preparations for #23
---

* Fix recursive redirects.

* Put a path that caused the function to be triggered into context and fill it correctly.

* Revert cyclic redirects fix.

* Code review fixes.

* Update docs.

* Rename invocationPath to invocationRoute

* Merge branch 'master' into kb/fix-context-from-value

* Instead of publishing an extra property to context, populate callback's `this` with the route that the function was defined in.
vlukashov pushed a commit that referenced this issue Jun 8, 2018
preparations for #23
---
* add a `chain` property to the resolver result

The chain property contains the path of the route that has returned the result in the routes tree (an array of routes from the root of the routes tree to a leaf).

If the result is returned by an action which obtained it by calling `next()` the returned chain contains only the path to that action's route.

* Activate all routes.

* Allow processing routes with empty paths.

* Fix merge leftowers.

* reivew fixes

 - explicitly skip the synthetic root route instead of all '' routes
 - compare routes for reference equality instead of comparing route paths
 - always initialize context.__resolutionChain

* Rework inactivate approach.

* Update action tests.

* Fix promise handling, add test.

* optimized the construction of `context.chain`

Construct the chain once after resolve is done by walking up the routes tree from the resolved route to the root, instead of updating the chain all the time during the routes tree traversal.

* address review comments

* Remove unused property.
vlukashov pushed a commit that referenced this issue Jun 11, 2018
Vaadin.Router will call the following callbacks on the view Web Component (if defined):
 - `onBeforeEnter` - before attaching a view Web Component to the DOM
 - `onBeforeLeave` - before detaching a view Web Component from the DOM
 - `onAfterEnter` - after attaching a view Web Component to the DOM (after the connected callback is called)

Fixes #23

---
* Support `onBeforeEnter` and `onBeforeLeave` navigation lifecycle
events.

* Make `onBefore...` callbacks have their element as `this`

* New implementation.

* add basic tests for lifecycle events order

 - add an x-spy-component custom element that records the order in which its callbacks are called (so that unit tests are easier to write)

* improve the x-spy component

* Update lifecycle tests.

* modify tests to address all review suggestions

* Merge remote-tracking branch 'origin/feature/23-lifecycle-events-review-suggestions' into kb/23_lifecycle-events

* Test fixes.

* Remove unnecessary return value.
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

No branches or pull requests

2 participants