select()method on @ngrx's
Storeclass. This method creates and returns an
Observablethat is bound to a specific property in your application state.
currentValue, we can pass in a strings as parameters, where each string plucks a single property from the application state one at a time in the order specified:
select()allows for several variations of strings to be passed in, it has it's shortcomings - namely you won't actually know if the plucking is working properly until you execute your code.
select()allows you to select values using functions too, which makes things more type-safe and your selectors will be more refactorable by your IDE.
Storeand select values directly in your Angular components, it's considered to be a best practice to wrap this functionality into separate services. This approach encapsulates all of the selection logic and eliminates any duplication where the selection path is repeated throughout your application.
getCurrentValue()method also applies a
filter()to ensure that subscribers do not receive any falsy values. This greatly simplifies the code and templates in your components, since they don't have to repeatedly consider the falsy case everywhere the value is used.