aptlyundecided / TomatoProgramming

1x 25 minute of programming as often as I can
0 stars 0 forks source link

Create a basic NgRx action/reducer/selector pipe #2

Closed aptlyundecided closed 4 years ago

aptlyundecided commented 4 years ago

I want to see a little bit more about what is happening in the relationship between actions, reducers, and selectors.

For example, I have no idea how to access a property of a selector. The most fundamental of items for this I have no clue. Time to change that.

aptlyundecided commented 4 years ago

Actions:

Reducers:

Selectors:

The guide is really fantastic. If you'll take the time to read it, it describes all that's needed to get up and going.

aptlyundecided commented 4 years ago

Ok, I am creating a basic 'programmer' object which is a sort of state tracking class for a programmer.

The typical: coffee sips: number energy_meter: number

Stuff like that.

I want to be able to display the stats of a single programmer, and make changes to them, and see that bound into the browser.

Nothing crazy beautiful or anything like that. I just want to see the data changing, which will mean that the NgRx system is being implemented at least partially correct.

aptlyundecided commented 4 years ago

This turned out to be fairly hard to wrap my head around!

In some kind of way, the context of a reducer is passed to a selector. I don't really understand how, but I can just say that when you call a selector from a store pipe, that must be how the context is shared, because the selectors are plain old functions, and if you have them in their own separate module, there is no import which would allow that function to know of the component OR the store context.

So it took me a few hours to really get what was happening! And I am confident that I still don't really understand what's happening. I just know how to build some pipelines, it doesn't mean I know how those pipelines are working.