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

Can Enumeration.options.beforeFreeze be eliminated? #77

Open
samreid opened this issue Dec 6, 2019 · 3 comments
Open

Can Enumeration.options.beforeFreeze be eliminated? #77

samreid opened this issue Dec 6, 2019 · 3 comments

Comments

@samreid
Copy link
Member

samreid commented Dec 6, 2019

From #50, we now have rich enumerations. Can we use that instead of beforeFreeze and delete beforeFreeze?

@samreid samreid self-assigned this Dec 6, 2019
samreid added a commit to phetsims/circuit-construction-kit-common that referenced this issue Dec 6, 2019
@samreid
Copy link
Member Author

samreid commented Dec 6, 2019

It looks like occurrences of beforeFreeze dealing with enumeration values can be replaced with Enumeration.byMap values. However, several occurrences are assigning static enumeration methods like MyEnumeration.staticMethod(...) using beforeFreeze. I wonder if there is a better way for doing this. Perhaps subtyping Enumeration and adding static methods would work? Or maybe the Enumeration shouldn`t be frozen and we can set static attributes on it the way we used to?

@jonathanolson what do you recommend?

UPDATE: What about freezing KEYS and VALUES but not the Enumeration instance itself?

@samreid samreid assigned jonathanolson and samreid and unassigned samreid Dec 6, 2019
@jonathanolson
Copy link
Contributor

Subtyping Enumeration sounds like something we'd do for a different class of enumerations, we really want to add methods to a single Enumeration object. I guess the freeze is to make sure we don't overwrite object values... maybe we could add a way of adding static information in another way? (An options object that gets extended into the enumeration object itself? A method addStatic or something that we can add methods/values with, e.g. SomeEnumeration.addStatic( 'getSomething', () => 5 )`)

Ideally we want to prevent SomeEnumeration.SOME_VALUE = 5 (which the freeze on the Enumeration itself provides), but we want to allow the equivalent of SomeEnumeration.someMethod = ...

@samreid
Copy link
Member Author

samreid commented Jul 15, 2020

I don't have any plans to work on this in the near future. Unassigning.

@samreid samreid removed their assignment Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants