Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Integrate Redux devtools into an ngrx Angular Application

    angularAngular
    ^7.0.3
    ngrxNgRx

    The benefits of adopting redux to handle state management in your application will become suddenly and almost magically apparent the second you have to debug your application with the Redux devtools extension. The best part is that we can leverage devtools in our ngrx Angular application in just a couple lines of code. In this lesson, we are going to take a quick tour on how to set up devtools in your application and how to use it to examine action objects, application state, and even time travel.

    Code

    Code

    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: In this lesson, we are going to take a quick detour, and I want to talk about a super awesome tool that I use all the time when I'm developing NgRx within my Angular applications. That is the Redux DevTools, which coincidentally integrates very easily with an NgRx application.

    If we look here in the NgModule imports, we are importing the store DevTools module. We're calling our instrument and we're giving it a max age of 10. Now, you could set this to three, or five, or whatever you want. I just like to set it to 10. That is really augurous to it on the Angular side to integrating with the DevTools.

    Now in our application, if you hop into the developer tools and you've installed the Redux DevTools, you should see this tab. Now occasionally, what you're going to see is that, store was not found as in the error right here.

    Since we're here real quick, let's click on the instructions, so that you can see where this DevTools extension is coming from. You can see all of the details here if you want to dig in a little bit more.

    Hopping back to the app, we're just going to refresh. This is what you're going to see. As actions are fired, they are picked up in the inspector. We can see that stores in it, affects in it, but as we start to manipulate things such as let's update the application, as soon as we click save, you're going to see that the update action was fired.

    This will have the action object itself and what you wanted to over to a dispatching into the reducer via the action object.

    From here, you can see that we deleted an action or deleted a project. You can see that delete action here as well as you can see that we got delete. You can now step in as well into state and see the overall application state.

    It's very, very handy to be able at any given time to see all the state within your application. Now, one other thing that you can do that I think is pretty amazing is that you can start to time travel. If you click on this arrow, you can step back and it will rollback that action.

    You can start to move backwards and you can move forward to play a sequence of events and to see how it interacts with the state within your application, which is really, really, really handy for troubleshooting and debugging common scenarios.

    Most of the time when something goes away from me, it's because I've simply made an erroneous assumption about of the state of my data. This is a quick tour of the Redux DevTools and how it's integrated into an Angular application.

    Now, one thing I want to call out here is notice that our actions are very, very generic, is update and delete. What we want to do is find a way to provide more actionable information, as we are troubleshooting our application through the DevTools.

    This is why, using these very generic kind of opaque action objects are a bad idea. What you would ultimately want to do is use strongly-typed actions that are very descriptive.

    With that said, this is how you integrate the DevTools into Angular. It's a very handy tool I recommend using it frequently as you can step forward, backwards through your application state.