Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
markwhitfeld opened this issue Jul 4, 2024 · 3 comments
Open

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

markwhitfeld opened this issue Jul 4, 2024 · 3 comments

Comments

@markwhitfeld
Copy link
Member

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.
@dmrickey
Copy link

dmrickey commented Aug 13, 2024

If I have 20 different properties in my state, am I supposed to write 20 different selectors instead of just passing an inline function to the select statement? (more specifically regarding nested properties - I don't see that there are any shortcuts for creating those)

@markwhitfeld
Copy link
Member Author

@dmrickey if you have the time, I would be interested to understand your use cases.
Reach out to me on the NGXS Discord or Slack and we can have a chat.

@dmrickey
Copy link

@markwhitfeld
The discord link doesn't appear to be a permanent link as it seems to be expired (or possibly just a bad link). I've joined the Slack, but the chances of me seeing a response there after today are minimal at best :/. My discord user name is claudekennilol. I'm available there practically 24/7.
I'd love to be able to join discord and ask questions that will be more visible than here on github issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants