Skip to content

Simplify transition hooks #321

Closed
Closed
@yyx990803

Description

@yyx990803

Here's what I think of the current API:

  • The current list of hooks is a bit overwhelming. Do we actually need canActivate and canDeactivate? It seems activate and deactivate can already handle most use cases with transition.abort() and transition.redirect().
  • The data hook name is not that self-explanatory.
  • The way we determine the async-ness of these hooks is convoluted. Sync, Promises, callbacks... we should try to simplify it.

Idea

Some potential breaking changes for 0.8.0:

  • Remove canActivate and canDeactivate.
  • (Maybe?) Remove canReuse. The same component is always reusable. Handle route change in onChange.
  • Rename hooks, now we have just 3 of them:
    • onEnter: what activate used to be.
    • onLeave: what deactivate used to be.
    • onChange: what data used to be. The new name better explains when it is called (on every route change when the current component is active)
  • In addition: allow specifying onEnter and onLeave in the route config as well.
  • Open to suggestion: how do we simplify hook async-ness?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions