NgRX

view state, user information, entity data, user selection and input

what is state?

What is NgRx?

Set of reactive libraries for Agular.

NgRx = Redux patter + Angular

diagram here

Use NgRx when

-there is state everywhere

-getting data again and again

-notify everyone

Don't use NgRx

when you app is simple

the team is new to angular

you team has a good pattern

Redux Pattern

What is redux?

 

Redux is a predictable state container for javascript apps

Redux principles

-Single source of truth called the store

-State is read only and only changed by dispatching atcions

-changes are made using pure functions called reducers

Store

is a single source of truth

what should not go in the store?

-nshared state
-angular form state
-non-serializable state

 

Actions

login actions
toggle side menu
retrive data actions when initializing a component
start a global spinner action when saving data

ReducerS

user reducers to change the state

-reudcers is a pure function

 

what is a pure function?
pure and impure fucntiosn

 

pure function screenshot

Advantages of Redux

-Centralized immutable state

-Performance

-testability

-tooling

-component comunication

Redux is not great for making simple thing quickly. it's great for making really hard things simple- jani evakalio

Made with Slides.com