-
-
Notifications
You must be signed in to change notification settings - Fork 596
Initialise default attributes #322
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
Comments
Using the initialize() function is highly discouraged. It's supported for legacy reasons, but you should consider it deprecated. Here's how I would recommend implementing default attributes, with ES6 classes: class MyObject extends Parse.Object {
constructor(arguments) {
super('MyClassName');
this.set({
// default values
});
if (arguments) {
this.set(arguments);
}
}
// ... rest of the class
} (the arguments bit is so that you can still specify initial values to override the defaults) |
Thanks for the clarification... do you have a non-ES6 solution ? |
Sorry, I tend to encourage developers to adopt ES6 classes in their workflow. Can you show me how you attempted to implement |
I guess its the fear of the unknown... id did a quick look at ES6 compatibility in browsers and was worried that your ES6 solution may not work in older clients.... but maybe a shim is in order ? there is the full (angularjs) code for the factory in question:
thanks for the help! |
Okay, I think I figured out what's going on. #81 was intended to fix an issue with I'll see if I can fix this and push a new version to npm |
fixed in 03d14a0 |
What is the correct way to set defaults on attributes inside the initialize function
This issue was originally raised in #73 (also #216), and the suggested solution was to use
set()
.However if i use
this.set('fieldname', value);
it is not working.... do I have the incorrect format ?Also - assuming this community has access to the official documentation, it would help to update it (happy to help)
The text was updated successfully, but these errors were encountered: