-
Notifications
You must be signed in to change notification settings - Fork 55
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
Call set method for private member #114
Comments
You are right. The problem is that you can only use json2typescript with properties right now, not with getters and setters. If you do that, how can json2typescript know the actual name of the setter and getter? Of course, most people use the conventional On the other hand, is it really necessary to process json that comes from a server with a setter? Shouldn't be the data coming from a server already "sanitized"? I just had this discussion with my colleague @tobiasschweizer and I am not sure yet how to proceed. |
@andreas-aeschlimann Sometimes you want to update other component or variable when you set the value, for example make visible a div if the property has a special value. |
You could search for Regarding your second point: your client application consume some APIs (and you probably don't owned these APIs) and receive data that may not match with your model or the way you want to provide them to your users. |
Thumbs up for this idea. In some of my data classes, I have calls to other private functions after data is set. This worked great using Object.assign, because it calls your setter methods. Now that my data is just being set into the variable, I've lost that functionality. |
Hi,
first thing first, you did a great job! Thanks!
I have some enhancement to propose.
When you use a private member it is mainly because you want to process some stuff in the set (or get) method.
By mapping directly the value to the private member you miss all this stuff.
So it will be great to call the set method if it exists, otherwise you set directly the class member.
My 2 cents.
The text was updated successfully, but these errors were encountered: