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

Added enums use case #1428

Merged
merged 1 commit into from
Sep 4, 2023
Merged

Added enums use case #1428

merged 1 commit into from
Sep 4, 2023

Conversation

lucasbordeau
Copy link
Contributor

Added a specific use case for enums in the docs.

@lucasbordeau lucasbordeau merged commit 2ac32e4 into main Sep 4, 2023
@lucasbordeau lucasbordeau deleted the docs/enums branch September 4, 2023 09:35
goBackToPreviousHotkeyScope,
} = usePreviousHotkeyScope();

setHotkeyScopeAndMemorizePreviousScope(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmh ok, good one! I don't think it's clear enough:
I would put create two differents paragraphs, 1 for Graphql and 1 for internal libraries use case.

In the internal lib use case, I would take more time to expose the issue:

  • in some cases, we want to be able to pass a string amongst a list of string to a library (ex. setHotkeyScopeAndMemorizePreviousScope that can take "relation-picker" | "companies-table" as a valid scope)
  • however, the library code should not be aware of this specific list which is only a concern for the library api user. We don't want developers to add a new possibility to the library each time they need it. This means the library will accept any string as a valid input. setHotkeyScopeAndMemorizePreviousScope(scope: string)
  • in this case, we use enums to make sure that we are passing an authorized scope to the function (RelationPickerHotkeyScope.RelationPicker | AppHotkeyScope.CompaniesTable)

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

Successfully merging this pull request may close these issues.

3 participants