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

Generate constants for all Schema field names #78

Open
rnd256 opened this issue Jun 14, 2020 · 0 comments
Open

Generate constants for all Schema field names #78

rnd256 opened this issue Jun 14, 2020 · 0 comments

Comments

@rnd256
Copy link
Contributor

rnd256 commented Jun 14, 2020

In OnStateChangeHandler in Unity, I almost always find myself checking if change.Field matches a constant string before deciding which sub-handler to run. String matching like this is error-prone because issues can't be detected at compile time. This could be resolved by either:

  1. Providing OnChange support to individual fields rather than only on an object-level (I imagine this isn't possible across all Colyseus' platforms), or
  2. Making schema-codegen generate constants for all the field names in the schema, so that they can be used instead of the developer writing out the constant strings themselves.
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

1 participant