Defines route lifecycle method routerCanReuse, which is called by the router to determine whether a component should be reused across routes, or whether to destroy and instantiate a new component.

The routerCanReuse hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route.

If routerCanReuse returns or resolves to true, the component instance will be reused and the OnDeactivate hook will be run. If routerCanReuse returns or resolves to false, a new component will be instantiated, and the existing component will be deactivated and removed as part of the navigation.

If routerCanReuse throws or rejects, the navigation will be cancelled.

Example

{@example router/ts/reuse/reuse_example.ts region='reuseCmp'}

Constructors

CanReuse()

Properties

hashCode → int

Get a hash code for this object.

read-only, inherited
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
routerCanReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction) → dynamic

toString() → String

Returns a string representation of this object.

inherited