I have several routes each with a table that should load data from the server. How can I dispatch an action to the ngrx/store to load data from the server when a route with table become active?
Thanks
You can use the @ngrx/router-store that dispatches actions on different lifecycle steps.
Then add an effect that listen to ROUTER_NAVIGATED
for example filters on a specific location and dispatches the needed loading action.
@Effect()
$routerNavigated = this.actions$.ofType(ROUTER_NAVIGATED)
.pipe(filter(action => (/persons/g).test(action.payload.url)),
map(action => new LoadSomePersonsData()));