This post is meant to explain some of the magic behind the line of initialization code for Ngrx/Store that you put in the imports block of the NgModule. Working with provideStore is key to understanding how to setup your project wiht Ngrx, so let's get into it!
0 Comments
Here's an error I was having for the past few days that I'm a little embarrassed to admit. haha. As it t urns out the error was caused by me not returning anthing from a certain case of the swtich statement in my reducer function.
I've been working a lot recently with the Angular state management library ngr. I even wrote a blog post about setting up your Angular 2 project with ngrx/store and then a follow up post The Basics of"ngrx/effects", @Effect, and Async Middleware for "ngrx/store" in Angular 2. However, after taking a closer look at the official ngrx example project I learned a little trick that harnesses the power of TypeScript to make your coding experience even more fun and less error-prone.
I just went through a pretty embarasseing episode of fighting with a large codebase to figure out a bug, and it turned out in the end that the issues were being caused by improper use of the Object.assign method. In particular, I was using it to manage the state inside my reducer function in an ngrx store, and it was screwing with my whole app! I hope I can remember that you need to first pass in an empty object to Object.assign, and then you pass the object that you want to "assign onto" that empty object.
If you haven't already read my first post about setting up your angular 2 project with Ngrx/store then you should check that out first. In this post we will build on this state management architecture by learning about how to to think about asynchronous actions in the world of ngrx. We'll start with some simple examples and ultimately build up to @Effects that pull data from Firebase database. Let's get started!
|
AuthorThe posts on this site are written and maintained by Jim Lynch. About Jim...
Categories
All
Archives
March 2023
|