How to use the boring-router.RouteMatch.rest function in boring-router

To help you get started, we’ve selected a few boring-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 makeflow / boring-router / packages / boring-router-react / examples / hooks / main.tsx View on Github external
$match: '',
  },
  account: true,
  profile: {
    $exact: true,
    $children: {
      details: true,
    },
  },
  about: {
    $query: {
      source: true,
    },
  },
  notFound: {
    $match: RouteMatch.rest,
  },
});

route.account.$beforeEnter(() => {
  route.about.$push({source: 'reaction'});
});

route.profile.$beforeEnter(match => {
  console.info('before enter profile');

  if (match.$exact) {
    match.details.$push();
  }
});

route.profile.$afterEnter(() => {
github makeflow / boring-router / packages / boring-router-react / examples / service / main.tsx View on Github external
$match: '',
  },
  account: {
    $children: {
      id: {
        $match: RouteMatch.segment,
        $extension: {
          tick: undefined! as number,
          account: undefined! as Account,
        },
      },
    },
  },
  profile: true,
  notFound: {
    $match: RouteMatch.rest,
  },
});

type AccountIdRouteMatch = typeof route.account.id;

class AccountIdRouteService implements IRouteService {
  private timer!: number;

  @observable
  tick!: number;

  constructor(private match: AccountIdRouteMatch) {}

  get account(): Account {
    let {id} = this.match.$params;
    return new Account(id);
github makeflow / boring-router / packages / boring-router-react / examples / redirect / main.tsx View on Github external
const router = new Router(history);

const route = router.$route({
  default: {
    $match: '',
  },
  account: true,
  profile: true,
  about: {
    $query: {
      source: true,
    },
  },
  notFound: {
    $match: RouteMatch.rest,
  },
});

@observer
export class App extends Component {
  render(): ReactNode {
    return (
      <>
        <h1>Boring Router</h1>
        
          <p>Home page</p>
          <div>
            Account
          </div>
          <div>
            About</div>
github makeflow / boring-router / packages / boring-router-react / examples / basic / main.tsx View on Github external
import {BrowserHistory, Link, Route} from '../../bld/library';

const history = new BrowserHistory();

const router = new Router(history);

const route = router.$route({
  default: {
    $match: '',
  },
  account: true,
  about: true,
  revert: true,
  notFound: {
    $match: RouteMatch.rest,
  },
});

route.revert.$beforeEnter(() =&gt; false);

@observer
export class App extends Component {
  render(): ReactNode {
    return (
      &lt;&gt;
        <h1>Boring Router</h1>
        
          <p>Home page</p>
          <div>
            Account
          </div>
github makeflow / boring-router / packages / boring-router-react / examples / parallel-routes / main.tsx View on Github external
const router = new Router&lt;'popup' | 'sidebar'&gt;(history);

const primaryRoute = router.$route({
  default: {
    $match: '',
  },
  news: true,
  about: {
    $exact: true,
    $children: {
      test: true,
    },
  },
  contact: true,
  notFound: {
    $match: RouteMatch.rest,
  },
});

const popupRoute = router.$route('popup', {
  account: {
    $exact: true,
    $children: {
      login: true,
      register: true,
    },
  },
  profile: true,
});

const sidebarRoute = router.$route('sidebar', {
  cart: true,

boring-router

A type-safe MobX router with parallel routing support.

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Similar packages