-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
new: className in subclass constructor #1315
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1315 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 60 60
Lines 5851 5847 -4
Branches 1314 1312 -2
=========================================
- Hits 5851 5847 -4
Continue to review full report at Codecov.
|
Can you write a failing test? I kinda know what you are trying to do. |
Yes, the main problem is that subclassing doesn't work without it('can use on ParseObject subclass for multiple Parse.Object class names', () => {
class MyParseObjects extends ParseObject {
constructor() {
super();
}
doSomething() {
return 5;
}
static readOnlyAttributes() {
return ['readonly', 'static', 'frozen'];
}
}
ParseObject.registerSubclass('TestObject', MyParseObjects);
ParseObject.registerSubclass('TestObject1', MyParseObjects);
ParseObject.registerSubclass('TestObject2', MyParseObjects);
const obj = new MyParseObjects('TestObject');
expect(obj.className).toBe('TestObject');
const obj1 = new MyParseObjects('TestObject1');
expect(obj1.className).toBe('TestObject1');
const obj2 = new MyParseObjects('TestObject2');
expect(obj2.className).toBe('TestObject2');
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick nit. Nice catch!
I’m surprise nobody caught this. Should look into #924 |
Hi,
Let's say you want to create a global function
getName
on all your Parse.Objects. Let's say you have 4 different classes. Here's how you'd have to do that now:Now, obviously this doesn't apply to all use cases, but this allows a
registeredSubclass
to have multiple class names, meaning that you can create one overhead class for multiple Parse Objects.