RxJs Store in Angular 5 - Saving application parameters / data

user8398743

I am using Angular 5 in a project and I am not sure what Redux / RxJs Store.

I've read about it but I'm not sure I understand it's use yet.

I know it's used so you know the application state, but what does the application state mean...

Does is mean that it saves all parameters and data ... what is it keeping a history of?

Julius Dzidzevičius

State, in short is:

if ($('.someDiv').hasClass('.active') {
  // make it glow
}

It just checks the state of the .someDiv element.

And writing your application you start with initial state and later your code, in general, keeps changing various states. You build functions over functions, modules over modules etc. And they all keep some states at particular time. And those states determines what actions must be taken.

When application is simple its easy to catch needed states and run those actions, but in complex apps you have many functions that are spread all over your application but are 'hired' for the some job. In such case, you might run into issues if ordering goes wrong, if some function changes some state and gets some weird / unexpected behaviour - that is hard to debug.

Redux main feature is that it controls that flow and is always 'close' to these functions. Its like a main headquarters of your army of functions - it controls the state and notifies functions squads (subscribers) when it is the moment to take actions. It also benefits that you dont need to pass those states fourth and backwards in your application - store (headquarters) is always 'close'.

But I personally haven't yet needed to use Redux and it is a common mistake to use Redux when it is not needed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related