lit-ui-router / UiOnParamsChanged
Interface: UiOnParamsChanged
Defined in: packages/lit-ui-router/src/interface.ts:35
Interface for components that respond to parameter changes.
When a component implements this interface, UI-Router will call the uiOnParamsChanged method whenever dynamic parameter values change without destroying and recreating the component.
Example
class UserDetail extends LitElement implements UiOnParamsChanged {
uiOnParamsChanged(newParams: RawParams, trans?: Transition) {
console.log('Parameters changed:', newParams);
// React to the new userId
if (newParams.userId) {
this.loadUser(newParams.userId);
}
}
}See
Methods
uiOnParamsChanged()
uiOnParamsChanged(newParams, trans?): void;Defined in: packages/lit-ui-router/src/interface.ts:54
A UI-Router view has a Lit Component (see NormalizedLitViewDeclaration.component). The Component may define component-level hooks which UI-Router will call at the appropriate times. These callbacks are similar to Transition Hooks (IHookRegistry), but are only called if the view/component is currently active.
The uiOnParamsChanged callback is called when parameter values change.
This callback is used to respond dynamic parameter values changing. It is called when a transition changed one or more dynamic parameter values, and the routed component was not destroyed.
It receives two parameters:
- An object with (only) changed parameter values. The keys are the parameter names and the values are the new parameter values.
- The Transition which changed the parameter values.
Parameters
| Parameter | Type |
|---|---|
newParams | RawParams |
trans? | Transition |
Returns
void