In my new role I've been given the opportunity to really dig into React, learn a lot about it, and build an application with it. I had previously used Ngrx in Angular 2 so it was interesting to go back to the original Redux library after having used the Angular step-cousin. After a few small roadblocks the application is progressing rather smoothly, and I have to say I think Redux is pretty dang awesome.
If you were using an older version of angular CLI before it had aot built into it then you may start to receive these errors when you run you usual `ng serve` or `ng build` commands:
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 7:3 in the original .ts file), resolving symbol mainStoreReducer in /.../, resolving symbol AppModule in /../, resolving symbol AppModule in /../, resolving symbol AppModule in /../
As you may have guessed from the title, this post is all about understanding what selectors are in an Ngrx Angular 2 application and why one should want to use them. I'll admit it; for a while I didn't use selectors at all. The truth is that you don't *need* them to get a basic project up and running with Ngrx (and that's why I don't talk about them in my Getting Set Up With With Ngrx blog post), but as your application grows along with your understanding of Ngrx you may eventually want to refactor your code and the way you select data from the state to improve your project's consistency and prevent unnecessary duplication. So without further ado, let's talk about selectors!
If you've taken a look at some open source projects that use Ngrx such as example-app, ngrx-examples , or angular-nye-advanced-ngrx then you may have noticed that they have an interesting way of defining Action types. In this post I'll go over why we use the "type" method and why we construct the Action strings in this specific style. Big thanks to Xavier, @xlozingues, for staying at the office late on a Friday to help me understand this. ?
Yep, another blog post about Angular 2 and Ngrx. In this post we'll look at some ways to create @Effects that don't return an action to the reducer and when you might want to do this.
The posts on this site are written and maintained by Jim Lynch. About Jim...