MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / navChanged

Method navChanged

core/src/components/router/router.tsx:187–218  ·  view source on GitHub ↗
(direction: RouterDirection)

Source from the content-addressed store, hash-verified

185 /** @internal */
186 @Method()
187 async navChanged(direction: RouterDirection): Promise<boolean> {
188 if (this.busy) {
189 printIonWarning('[ion-router] - Router is busy, navChanged was cancelled.');
190 return false;
191 }
192 const { ids, outlet } = await readNavState(window.document.body);
193 const routes = readRoutes(this.el);
194 const chain = findChainForIDs(ids, routes);
195 if (!chain) {
196 printIonWarning(
197 '[ion-router] - No matching URL for',
198 ids.map((i) => i.id)
199 );
200 return false;
201 }
202
203 const segments = chainToSegments(chain);
204 if (!segments) {
205 printIonWarning('[ion-router] - Router could not match path because some required param is missing.');
206 return false;
207 }
208
209 // navChanged is an outlet-driven URL sync. Only keep the fragment when
210 // the path is unchanged; on a real navigation it refers to an anchor on
211 // the page being left and would be stale.
212 const newPath = generatePath(segments);
213 const fragment = newPath === this.previousPath ? this.getFragment() : undefined;
214 this.setSegments(segments, direction, undefined, fragment);
215
216 await this.safeWriteNavState(outlet, chain, ROUTER_INTENT_NONE, segments, null, ids.length);
217 return true;
218 }
219
220 /** This handler gets called when a `ion-route-redirect` component is added to the DOM or if the from or to property of such node changes. */
221 private onRedirectChanged() {

Callers 2

successMethod · 0.80
notifyRouterMethod · 0.80

Calls 9

getFragmentMethod · 0.95
setSegmentsMethod · 0.95
safeWriteNavStateMethod · 0.95
printIonWarningFunction · 0.90
readNavStateFunction · 0.90
readRoutesFunction · 0.90
findChainForIDsFunction · 0.90
chainToSegmentsFunction · 0.90
generatePathFunction · 0.90

Tested by

no test coverage detected