Called by the Router during recognition phase of a navigation.
If the new child component has a different Type than the existing child component,
this will resolve to false
. You can't reuse an old component when the new component
is of a different Type.
Otherwise, this method delegates to the child component's routerCanReuse
hook if it exists,
or resolves to true if the hook is not present.
Source
Future<bool> routerCanReuse(ComponentInstruction nextInstruction) { Future<bool> result; if (this._currentInstruction == null || this._currentInstruction.componentType != nextInstruction.componentType) { result = new Future.value(false); } else { result = this._componentRef.then((ComponentRef ref) { if (hasLifecycleHook(hook_mod.routerCanReuse, ref.instance)) { return ((ref.instance as CanReuse)) .routerCanReuse(nextInstruction, this._currentInstruction); } else { return nextInstruction == this._currentInstruction || (nextInstruction.params != null) && (_currentInstruction.params != null) && const MapEquality().equals( nextInstruction.params, this._currentInstruction.params); } }); } return result; }