How store and router together work in angular ?

3.59K viewsProgrammingAngular
0

How store and router together work in angular ?

Answered question
0

The ngrx Store is a central source of truth in angular to which all components connect to.  It holds a state tree which is a snapshot of the entire application state.
Similarly ngrx also provides a router store which provides 5 router navigation actions as below:-

routerRequestAction
routerNavigationAction
routerNavigatedAction
routerCancelAction
routerErrorAction

Actions are events which are dispatched at different stages when a route change is detected which in turn notifies the reducer to update the state accordingly.
The angular component which has subscribed to state changes using RxJS gets notified about the change in state and can handle the business logic there when state changes via router navigation.

Hope that answers the question.

Edited answer
Write your answer.

Categories