With NGXS v18, we have started to push towards better type safety for selectors.
The challenge is that we have users who use old mechanisms that are not type-safe and they would need guidance on converting their code to a more type-safe equivalent. Not only that, but there is an opportunity here to showcase all of the different helpers available.
We should definitely cover:
Use a StateToken instead of the State Class to select from a state
and the alternative of using createSelector with some type casting to wrap an existing State Class as a type-safe selector
createSelector([MyState], s => s as MyStateModel)
Using createPropertySelectors to create smaller slices of your state
Using createPickSelector to optimise a selector that has fewer dependencies
Using createMappedSelector to combine selectors for view models, etc.
Description
With NGXS v18, we have started to push towards better type safety for selectors. The challenge is that we have users who use old mechanisms that are not type-safe and they would need guidance on converting their code to a more type-safe equivalent. Not only that, but there is an opportunity here to showcase all of the different helpers available.
We should definitely cover:
createSelector
with some type casting to wrap an existing State Class as a type-safe selectorcreateSelector([MyState], s => s as MyStateModel)
createPropertySelectors
to create smaller slices of your statecreatePickSelector
to optimise a selector that has fewer dependenciescreateMappedSelector
to combine selectors for view models, etc.