MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / setRouteId

Method setRouteId

core/src/components/nav/nav.tsx:367–428  ·  view source on GitHub ↗
(
    id: string,
    params: ComponentProps | undefined,
    direction: RouterDirection,
    animation?: AnimationBuilder
  )

Source from the content-addressed store, hash-verified

365 */
366 @Method()
367 setRouteId(
368 id: string,
369 params: ComponentProps | undefined,
370 direction: RouterDirection,
371 animation?: AnimationBuilder
372 ): Promise<RouteWrite> {
373 const active = this.getActiveSync();
374 if (matches(active, id, params)) {
375 return Promise.resolve({
376 changed: false,
377 element: active.element,
378 });
379 }
380
381 let resolve: (result: RouteWrite) => void;
382 const promise = new Promise<RouteWrite>((r) => (resolve = r));
383 let finish: Promise<boolean>;
384 const commonOpts: NavOptions = {
385 updateURL: false,
386 viewIsReady: (enteringEl) => {
387 let mark: () => void;
388 const p = new Promise<void>((r) => (mark = r));
389 resolve({
390 changed: true,
391 element: enteringEl,
392 markVisible: async () => {
393 mark();
394 await finish;
395 },
396 });
397 return p;
398 },
399 };
400
401 if (direction === 'root') {
402 finish = this.setRoot(id, params, commonOpts);
403 } else {
404 // Look for a view matching the target in the view stack.
405 const viewController = this.views.find((v) => matches(v, id, params));
406
407 if (viewController) {
408 finish = this.popTo(viewController, {
409 ...commonOpts,
410 direction: 'back',
411 animationBuilder: animation,
412 });
413 } else if (direction === 'forward') {
414 finish = this.push(id, params, {
415 ...commonOpts,
416 animationBuilder: animation,
417 });
418 } else if (direction === 'back') {
419 finish = this.setRoot(id, params, {
420 ...commonOpts,
421 direction: 'back',
422 animated: true,
423 animationBuilder: animation,
424 });

Callers

nothing calls this directly

Calls 6

getActiveSyncMethod · 0.95
setRootMethod · 0.95
popToMethod · 0.95
pushMethod · 0.95
matchesFunction · 0.90
resolveFunction · 0.85

Tested by

no test coverage detected