API Reference
Configuration File Winnetoujs package Constructos Mutables State Management Mutations Select Methods Winnetou Fx Router Translations Color Themes WBR Compiler
Docs Change Log Git Hub Pull Requests Guidelines Get in touch

Router


∯ Purpose

Creates routes.

∯ Syntax

.createRoutes(routes: object, [options: object])

.navigate(route: string)

.pass(route: string)

createRoutes

Method that creates WinnetouJs routes system.

router.js

import {Winnetou} from 'winnetoujs';

Winnetou.createRoutes({
        "/": () => {
            this.render()
        },
        "/profiles/:user": user => this.profile(user),
        "menu": () => this.menu()
    },
    {
        onBack: (route) => {
            console.log(
                 "This will be triggered when user press back button"
            );
        },
        onGo: (route) => {
            console.log(
                "This will be triggered when user go to a route"
            );
        },
    }
);


            

navigate

Calls route and changes app url.

router.js

import {Winnetou} from 'winnetoujs';

Winnetou.navigate(`/profile`);
Winnetou.navigate(`/user/${user.login}`)

  

pass

Calls route without changing app url. To use pass, do not use slashes.

router.js
  
  import {Winnetou} from 'winnetoujs';
  
  Winnetou.pass(`menu`);
  Winnetou.pass(`settings/${data.id}`)