Angular 5 and NGRX 5
I am attempting to run some custom validation after a users clicks a search button, and if the validation is successful, route to a new page.
I have an isError observable that is being populated from my store:
isError$: Observable<boolean>;
ngOnInit() {
this.isError$ = this.store$.select(
ShipmentLookupStoreSelectors.selectShipmentLookupError
);
}
I am calling the search action on my store as below:
onSearch() {
this.store$.dispatch(new ShipmentLookupStoreActions.Search());
}
What I am confused with is how/when to actually route to the new page? What I essentially want to happen is:
run validation
if success -> route to new page
if failure -> stay on same page with updated state (isError state will be updated to true, I have this working)
I've looked into ngrx router-store but am overall confused as the best way to implement this.