Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start method to router #402

Merged
merged 3 commits into from
Jun 24, 2019
Merged

Conversation

agubler
Copy link
Member

@agubler agubler commented Jun 19, 2019

Type: bug

The following has been addressed in the PR:

Description:

Currently the router uses the QueuingEvented implementation to queue events that happen before there are listeners attached.

However at the moment the registerRouterInjector helper, connects to the nav event automatically which means that any listeners added after calling registerRouterInjector will not receive the initial nav events.

This change introduces a start method to the router and an autostart property to the RouterOptions. The autostart property defaults to true which maintains the current behaviour, but when it is set to false it allows consumers to add listeners to the routing events before the router is "started". Once all the listeners have been configured, the start method is required to be called.

import Registry from '@dojo/framework/core/Registry';
import { registerRouterInjector } from '@dojo/framework/routing/RouterInjector';

const routes = [];
const registry = new Registry();
const router = registerRouterInjector(routes, registry, { autostart: false });

router.on('nav', () => {
    // add a listener that needs to catch the events
    // that occur on the initial navigation
});
router.start();

Resolves #386

Note: There are no other usages of QueuingEvented throughout framework and is not a recommended module to use externally so has been deleted from @dojo/framework/core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to connect to nav events that occur on router creation
2 participants