From the course: Angular State Management with NgRx

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Solution: Brainstorm state and actions for a weather app

Solution: Brainstorm state and actions for a weather app - Angular Tutorial

From the course: Angular State Management with NgRx

Solution: Brainstorm state and actions for a weather app

(upbeat music) - [Instructor] So here's one possible solution to this first challenge. On this first screen, the first obvious action is linked to the only thing we can do at this point, which is add new location. So that's the first action right here, add location, and its payload would have to be the entered zip code. Because of that, we can tell right away that our state will have a list of zip codes to store all of these locations. In my case, right now, the array of zip codes would have just one location, which is a New York City. We also see that the locations can be removed from the screen, so that's another action, remove location, that we would use to do that. Now each location in our list renders its current weather conditions, so we likely have a get current conditions action that takes a zip code as a payload. Such current conditions will be stored as part of our state as well. So we'll have a current conditions map in our state that maps a zip code to the current…

Contents