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

Design enhancement: a catch-all class decorator for modifications to modelSchema (which would subsume e.g. serializeAll) #150

Open
peey opened this issue Mar 18, 2021 · 0 comments

Comments

@peey
Copy link

peey commented Mar 18, 2021

serializeAll is not the only case which is insufficiently supported by class field decorators.

factory is another case. Without decorator support, this is what the user has to write:

getDefaultModelSchema(Todo).factory = context => (...)

but with decorator support, this is what user may instead write

@factory(context => (...))
class Todo {
  ...
}

But this got me thinking, shouldn't there be just one class-decorator to support both of these?

@serializr(() => {factory: ..., {props: {"*": true}}) 

The returned value could just be deep-merged into the model-schema as built-up by field decorators.

It does not save many characters of typing, but it's a much more uniform interface for the library user. Of the two interfaces offered by the library (decorator-based and non-decorator), it'll be ideal if the user using one of the interfaces doesn't have to deal with the other.

@peey peey changed the title Design enhancement: a catch-all decorator for modifications to modelSchema (which would subsume e.g. serializeAll) Design enhancement: a catch-all class decorator for modifications to modelSchema (which would subsume e.g. serializeAll) Mar 18, 2021
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