history#Action JavaScript Examples

The following examples show how to use history#Action. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: appRouter.js    From veso-web with GNU General Public License v2.0 6 votes vote down vote up
#goToRoute({ location, action }) {
        // Strip the leading "!" if present
        const normalizedPath = location.pathname.replace(/^!/, '');

        const route = this.allRoutes.get(normalizedPath);
        if (route) {
            console.debug('[appRouter] "%s" route found', normalizedPath, location, route);
            route.handler({
                // Recreate the default context used by page.js: https://github.com/visionmedia/page.js#context
                path: normalizedPath + location.search,
                pathname: normalizedPath,
                querystring: location.search.replace(/^\?/, ''),
                state: location.state,
                // Custom context variables
                isBack: action === Action.Pop
            });
        } else {
            console.info('[appRouter] "%s" route not found', normalizedPath, location);
            this.currentRouteInfo = {
                route: {},
                path: normalizedPath + location.search
            };
        }
    }