How to use @aurelia/router - 10 common examples

To help you get started, we’ve selected a few @aurelia/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / __tests__ / router / instruction-resolver.spec.ts View on Github external
//     
    //   
    // 
    // 
    //
    // /(a/(b/(c+d)+e/(f/(g)))+h)

    const [a, b, c, d, e, f, g, h] = [
      new ViewportInstruction('a'),
      new ViewportInstruction('b'),
      new ViewportInstruction('c'),
      new ViewportInstruction('d'),
      new ViewportInstruction('e'),
      new ViewportInstruction('f'),
      new ViewportInstruction('g'),
      new ViewportInstruction('h'),
    ];
    a.nextScopeInstructions = [b, e];
    b.nextScopeInstructions = [c, d];
    e.nextScopeInstructions = [f];
    f.nextScopeInstructions = [g];

    const instructions: ViewportInstruction[] = [a, h];

    const instructionsString = router.instructionResolver.stringifyViewportInstructions(instructions);
    console.log('Instructions', instructionsString);
    const parsedInstructions = router.instructionResolver.parseViewportInstructions(instructionsString);
    console.log('Parsed', parsedInstructions);
    const stringified = router.instructionResolver.stringifyViewportInstructions(parsedInstructions);
    console.log('Stringified', stringified);
    assert.strictEqual(stringified, instructionsString, `stringified`);
github aurelia / aurelia / packages / __tests__ / router / instruction-resolver.spec.ts View on Github external
//       
    //     
    //   
    // 
    // 
    //
    // /(a/(b/(c+d)+e/(f/(g)))+h)

    const [a, b, c, d, e, f, g, h] = [
      new ViewportInstruction('a'),
      new ViewportInstruction('b'),
      new ViewportInstruction('c'),
      new ViewportInstruction('d'),
      new ViewportInstruction('e'),
      new ViewportInstruction('f'),
      new ViewportInstruction('g'),
      new ViewportInstruction('h'),
    ];
    a.nextScopeInstructions = [b, e];
    b.nextScopeInstructions = [c, d];
    e.nextScopeInstructions = [f];
    f.nextScopeInstructions = [g];

    const instructions: ViewportInstruction[] = [a, h];

    const instructionsString = router.instructionResolver.stringifyViewportInstructions(instructions);
    console.log('Instructions', instructionsString);
    const parsedInstructions = router.instructionResolver.parseViewportInstructions(instructionsString);
    console.log('Parsed', parsedInstructions);
    const stringified = router.instructionResolver.stringifyViewportInstructions(parsedInstructions);
    console.log('Stringified', stringified);
    assert.strictEqual(stringified, instructionsString, `stringified`);
github aurelia / aurelia / packages / __tests__ / router / instruction-resolver.spec.ts View on Github external
//     
    //     
    //   
    //   
    //     
    //       
    //     
    //   
    // 
    // 
    //
    // /(a/(b/(c+d)+e/(f/(g)))+h)

    const [a, b, c, d, e, f, g, h] = [
      new ViewportInstruction('a'),
      new ViewportInstruction('b'),
      new ViewportInstruction('c'),
      new ViewportInstruction('d'),
      new ViewportInstruction('e'),
      new ViewportInstruction('f'),
      new ViewportInstruction('g'),
      new ViewportInstruction('h'),
    ];
    a.nextScopeInstructions = [b, e];
    b.nextScopeInstructions = [c, d];
    e.nextScopeInstructions = [f];
    f.nextScopeInstructions = [g];

    const instructions: ViewportInstruction[] = [a, h];

    const instructionsString = router.instructionResolver.stringifyViewportInstructions(instructions);
    console.log('Instructions', instructionsString);
github aurelia / aurelia / packages / __tests__ / router / viewport-content.spec.ts View on Github external
it('resolves component instance from type', async function () {
      const Local = define({ name: 'local', template: 'local' }, null);
      const Global = define({ name: 'global', template: 'global' }, null);
      const { container, router } = await $setup([Local]);

      container.register(Global);
      // Registration.alias(CustomElement.keyFrom('global'), Global).register(container);

      const viewport = new ViewportContent(Global, null, null, router.container as unknown as IRenderContext);
      const component = viewport.toComponentInstance(router.container as unknown as IRenderContext);
      assert.strictEqual(component.constructor, Global, `component.constructor`);
    });
  });
github aurelia / aurelia / test / realworld / src / components / profile / profile.ts View on Github external
import { inject } from '@aurelia/kernel';
import { IRouter, lifecycleLogger, ReentryBehavior } from '@aurelia/router';
import { Profile as ProfileModel } from 'shared/models/profile';
import { ProfileService } from 'shared/services/profile-service';
import { SharedState } from 'shared/state/shared-state';

@inject(SharedState, ProfileService, IRouter)
// @lifecycleLogger('profile')
export class Profile {
  public static parameters: string[] = ['name'];
  public reentryBehavior: string = ReentryBehavior.refresh;

  private username?: string;
  private profile?: ProfileModel;

  public constructor(
    private readonly sharedState: SharedState,
    private readonly profileService: ProfileService,
    private readonly router: IRouter) {
  }

  public canEnter() { console.log(`profile canEnter`); return true; }
  public created() { console.log(`profile created`); }
  public binding() { console.log(`profile binding`); }
  public bound() { console.log(`profile bound`); }
  public attaching() { console.log(`profile attaching`); }
  public attached() { console.log(`profile attached`); }
github aurelia / aurelia / packages / __tests__ / router / browser-navigator.spec.ts View on Github external
function createFixture() {
    const ctx = TestContext.createHTMLTestContext();
    const { lifecycle, scheduler, dom } = ctx;
    // const originalWnd = ctx.wnd;

    // const mockWnd = new MockWindow(originalWnd, originalWnd.history, originalWnd.location);
    // const addEventListener = createSpy(mockWnd, 'addEventListener');
    // const removeEventListener = createSpy(mockWnd, 'removeEventListener');

    // (DOM as Writable).window = mockWnd;

    const sut = new BrowserNavigator(scheduler, dom);
    const mockBrowserHistoryLocation = new MockBrowserHistoryLocation();
    mockBrowserHistoryLocation.changeCallback = sut.handlePopstate;
    sut.history = mockBrowserHistoryLocation as any;
    sut.location = mockBrowserHistoryLocation as any;

    function tearDown() {
      // (DOM as Writable).window = originalWnd;
    }

    callbackCount = 0;
    const callback = ((info) => {
      callbackCount++;
    });

    return { sut, tearDown, callback, lifecycle };
  }
github aurelia / aurelia / packages / aurelia / dist / umd / index.js View on Github external
exports.isNumeric = kernel_1.isNumeric;
    exports.camelCase = kernel_1.camelCase;
    exports.kebabCase = kernel_1.kebabCase;
    exports.pascalCase = kernel_1.pascalCase;
    exports.toArray = kernel_1.toArray;
    // nextId,
    // resetId,
    // compareNumber,
    // mergeDistinct,
    // isNumberOrBigInt,
    // isStringOrDate,
    exports.bound = kernel_1.bound;
    var router_1 = require("@aurelia/router");
    // Nav,
    exports.NavRoute = router_1.NavRoute;
    exports.IRouter = router_1.IRouter;
    exports.Router = router_1.Router;
    // IViewportOptions,
    // Viewport,
    // ContentStatus,
    // ViewportContent,
    exports.ViewportInstruction = router_1.ViewportInstruction;
    exports.RouterConfiguration = router_1.RouterConfiguration;
    exports.RouterRegistration = router_1.RouterRegistration;
    var runtime_1 = require("@aurelia/runtime");
    // CallFunctionExpression,
    // connects,
    // observes,
    // callsFunction,
    // hasAncestor,
    // isAssignable,
    // isLeftHandSide,
github aurelia / aurelia / packages / aurelia / dist / umd / index.js View on Github external
exports.IEventAggregator = kernel_1.IEventAggregator;
    exports.isNumeric = kernel_1.isNumeric;
    exports.camelCase = kernel_1.camelCase;
    exports.kebabCase = kernel_1.kebabCase;
    exports.pascalCase = kernel_1.pascalCase;
    exports.toArray = kernel_1.toArray;
    // nextId,
    // resetId,
    // compareNumber,
    // mergeDistinct,
    // isNumberOrBigInt,
    // isStringOrDate,
    exports.bound = kernel_1.bound;
    var router_1 = require("@aurelia/router");
    // Nav,
    exports.NavRoute = router_1.NavRoute;
    exports.IRouter = router_1.IRouter;
    exports.Router = router_1.Router;
    // IViewportOptions,
    // Viewport,
    // ContentStatus,
    // ViewportContent,
    exports.ViewportInstruction = router_1.ViewportInstruction;
    exports.RouterConfiguration = router_1.RouterConfiguration;
    exports.RouterRegistration = router_1.RouterRegistration;
    var runtime_1 = require("@aurelia/runtime");
    // CallFunctionExpression,
    // connects,
    // observes,
    // callsFunction,
    // hasAncestor,
    // isAssignable,
github aurelia / aurelia / packages / aurelia / dist / umd / index.js View on Github external
exports.camelCase = kernel_1.camelCase;
    exports.kebabCase = kernel_1.kebabCase;
    exports.pascalCase = kernel_1.pascalCase;
    exports.toArray = kernel_1.toArray;
    // nextId,
    // resetId,
    // compareNumber,
    // mergeDistinct,
    // isNumberOrBigInt,
    // isStringOrDate,
    exports.bound = kernel_1.bound;
    var router_1 = require("@aurelia/router");
    // Nav,
    exports.NavRoute = router_1.NavRoute;
    exports.IRouter = router_1.IRouter;
    exports.Router = router_1.Router;
    // IViewportOptions,
    // Viewport,
    // ContentStatus,
    // ViewportContent,
    exports.ViewportInstruction = router_1.ViewportInstruction;
    exports.RouterConfiguration = router_1.RouterConfiguration;
    exports.RouterRegistration = router_1.RouterRegistration;
    var runtime_1 = require("@aurelia/runtime");
    // CallFunctionExpression,
    // connects,
    // observes,
    // callsFunction,
    // hasAncestor,
    // isAssignable,
    // isLeftHandSide,
    // isPrimary,
github aurelia / aurelia / packages / aurelia / dist / umd / index.js View on Github external
// compareNumber,
    // mergeDistinct,
    // isNumberOrBigInt,
    // isStringOrDate,
    exports.bound = kernel_1.bound;
    var router_1 = require("@aurelia/router");
    // Nav,
    exports.NavRoute = router_1.NavRoute;
    exports.IRouter = router_1.IRouter;
    exports.Router = router_1.Router;
    // IViewportOptions,
    // Viewport,
    // ContentStatus,
    // ViewportContent,
    exports.ViewportInstruction = router_1.ViewportInstruction;
    exports.RouterConfiguration = router_1.RouterConfiguration;
    exports.RouterRegistration = router_1.RouterRegistration;
    var runtime_1 = require("@aurelia/runtime");
    // CallFunctionExpression,
    // connects,
    // observes,
    // callsFunction,
    // hasAncestor,
    // isAssignable,
    // isLeftHandSide,
    // isPrimary,
    // isResource,
    // hasBind,
    // hasUnbind,
    // isLiteral,
    // arePureLiterals,
    // isPureLiteral,