Skip to content

📚[DOCS]: Add documentation about Selector Type Safety #2182

@markwhitfeld

Description

@markwhitfeld

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:

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions