-
Notifications
You must be signed in to change notification settings - Fork 584
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
Fix types for Object Listener #4338
Conversation
@@ -1,3 +1,4 @@ | |||
c76131748cbb048e78a987eb234d8a9609e26430 | |||
f38d8cf7cac992767a451d2f3cf3310e3546bf6f | |||
fa80f12bf3fbfe1337ae69e12c59051fac347001 | |||
99e64a8e990d2579bcfe382f755edbc61f70af4e |
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.
Was this on purpose?
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.
Yes...the types document still had our merge commit from version 10.5.0
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.
Somehow that seems to exist across multiple SHAs.
bb49df8
to
d7cffb9
Compare
When a class extends Realm.Object, adding a listener to an instance of the object would not correctly type the object returned in the callback. With this change, the callback returns an object of the same type as the instance it was called from.
d7cffb9
to
3d26608
Compare
@@ -251,16 +251,16 @@ declare namespace Realm { | |||
/** | |||
* @returns void | |||
*/ | |||
addListener(callback: ObjectChangeCallback): void; | |||
addListener(callback: ObjectChangeCallback<this>): void; |
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.
Nice trick ✨
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.
Game changer.
When a class extends Realm.Object, adding a listener to an instance of the object would not correctly type the object returned in the callback. With this change, the callback returns an object of the same type as the instance it was called from.
When a class extends Realm.Object, adding a listener to an instance of the
object would not correctly type the object returned in the callback.
With this change, the callback returns an object of the same type as the
instance it was called from.
This closes #4337
☑️ ToDos
Compatibility
label is updated or copied from previous entryBreaking
label has been applied or is not necessaryIf this PR adds or changes public API's: