Check out a free preview of the full Reactive Angular with NgRx course

The "Summary" Lesson is part of the full, Reactive Angular with NgRx course featured in this preview video. Here's what you'd learn in this lesson:

Lukas summarizes what was covered in the course, and introduces reasoning why the different tools might be used.

Preview
Close

Transcript from the "Summary" Lesson

[00:00:00]
>> Lukas Ruebbelke: That's it. That's everything in the nutshell. All the steps that I've done, more of less, and actually there are a few more changes i will make, is in the project repository, under the Wiki, so these will pretty much for the most part match up with the steps, but, we've now kind of come to the full arc of basic Redux.

[00:00:24]
That's store, actions, reducers, selectors and entity. But from there, the asynchronous piece, which I would say is probably the most complicated piece because you're isolating all your control flow, the business is not attending to that place and then our computer selectors which if you're familiar is like higher other function with the race or double succession, pretty straight forward, and then just I think really nice sheen or layer of polish on top of it with facades.

[00:01:01]
And so this is currently how I build all my applications and it's working quite well. So for you doing a dashboard, or for anybody doing a dashboard, this is a really awesome way to something has changed and now it's feeding in to this kind of aggregated view of all this data.

[00:01:26]
And what you can also do for instance let's say, I had a collection of users with maybe like some different statistics on it, like here's your projects stats and here's your sales. So, imagine like ACRN with like, here's the sales that you've done. Well what you can do is have a single data source and then create custom selectors for here's your close rate, here's your burn down rate, here's your whatever.

[00:01:57]
And based on a single data set you can use that to compute different things and abstract out certain pieces. And so, now you're gonna have a dashboard with multiple kind of independent presentation components that is the master kind of collection changes instead it's recomputing the data it actually needs for that component but that data is still in one place.

[00:02:22]
So this is also for a dashboard. I think really, really key where I have a lot of, were I'm displaying data or a lot of data in a bunch of different ways and not having to kind of be like the data's over here, no it;s over here, now it's in this service, now it's in this component.

[00:02:44]
It's in one place. You change it in one place and it simplifies that entire communication flow. So just to kinda come back full circle, this is how, in angular application, you can reduce complexity at a massive scale. Move all your state into a single state tree. Single source of truth, any time that you have state in more than one place, it's confusing.

[00:03:11]
What's my single source of truth? You run into problems as well as having it essentially be read only that reduces shared immutable state. And by having small, very specific methods in your reducer that when I put this in I get this out. And so these are pure functions with complete referential transparency that they're very easy to test.

[00:03:39]
So one, code volume has went way down because everything is moving into their specific place, it promotes reuse and then finally flow of control. Two things. One, well, let me ask you a question. Would you rather cross a one-way street or a eight lane, super highway lane? Take your pick.

[00:04:01]
It's pretty obvious. When you cross a one lane street you have one thing to worry about. When you're reasoning about your data flow and it's not doing this, but this, it's very easy to say, where is this coming from? Somewhere from point A to point B something went wrong.

[00:04:17]
So that's really simplifies flow of control because everything moves in a kind of circular unidirectional way. But also, any kind of complex asynchronous, like control flow that involves business logic, now this goes into your effects that you can then control with observables, which are extremely powerful. And they are phenomenal for taking ahead this thing and I wanna move from here to here but I want to do these complex transformations along the way.

[00:04:55]
And so when we talk about application complexity as it pertains to state management, flow of control, and code volume, this to me takes the cake. For these reasons, state flows down, events flow up. Single source of truth, everything in its place

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now