Introduction
Up until now we have been taking a low level approach to state management. We have been working directly with the underlying concepts and seeing exactly how the data flow from our sources to our state works.
- We create a
sourcethat is an observable stream - We
subscribeto thatsourceto pull the data out - We
updateasignalusing the value from thesource
It is important to understand what is going on and doing everything more manually like this is a great way to learn the concepts.
In fact, I think it is fine to use the approach we have been using indefinitely — there is some boilerplate involved, but it is still reasonably simple to set up.
However, there is room to make things a bit easier by using some abstractions. Rather than doing everything manually, we could use a utility or library to hide away some of the repetitive work for us.
That is what we will be focusing on in this module. First, we will look at how we might create our own simple utility to make setting up our state a little bit easier. Then we will look at using a utility from a third party library that is going to make our lives a lot easier, and it is what we will continue to use moving forward.
We don’t really gain anything from the approaches we are going to use in this module other than it making our lives a bit easier and perhaps making the code more readable for others. This is preference based though, so if you don’t like the style we use in this module, it is certainly fine to keep doing what we have been doing so far with the manual subscribes (or maybe you can find some other utility or library that you prefer).