When injecting WizardSteps service to an NgRx effect a warning occurs that breaks further WizardSteps usage:
sebgroup-ng-wizard.js:424 No valid route config found for current route: "".
Make sure route guards provide a fallback if a access to a step is restricted and that inactive sub steps are handled too, using a wildcard route.
In our case, routes are configured correctly as described in the documentation. What is more, this doesn't happen when injecting WizardSteps to a regular Angular service.
Reproducing the issue
This issue can be reproduced in a sample seb-ng-wizard project (e.g. https://github.com/sebgroup/ng-wizard/tree/master/projects/seb-ng-wizard-lazy-demo):
- Install NgRx store and effects
- Create any effect and provide it in a module
- Inject WizardSteps to the created effect
- Launch the application and the before mentioned warning will appear.
Workaround
After playing around with it a little, we discovered that by extracting WizardSteps constructor code into a method and placing it in a timeout, the issue is resolved:
constructor(private router: Router, private _location: Location) {
setTimeout(() => {
this.init();
}, 0);
}
Uppon further investigation we saw that the error occurs because of undefined access to routes (line 43). In essence, this._config.config['_loadedConfig'].routes[0].children can't find _loadedConfig initially but works just fine with setTimeout(...). Perhaps a race condition occurs somewhere?
When injecting WizardSteps service to an NgRx effect a warning occurs that breaks further WizardSteps usage:
In our case, routes are configured correctly as described in the documentation. What is more, this doesn't happen when injecting WizardSteps to a regular Angular service.
Reproducing the issue
This issue can be reproduced in a sample seb-ng-wizard project (e.g. https://github.com/sebgroup/ng-wizard/tree/master/projects/seb-ng-wizard-lazy-demo):
Workaround
After playing around with it a little, we discovered that by extracting WizardSteps constructor code into a method and placing it in a timeout, the issue is resolved:
Uppon further investigation we saw that the error occurs because of undefined access to
routes(line 43). In essence,this._config.config['_loadedConfig'].routes[0].childrencan't find_loadedConfiginitially but works just fine withsetTimeout(...). Perhaps a race condition occurs somewhere?