Repository navigation
feat(observable): return this from on, once and off #11617
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,7 @@ class MediaQueryListImpl extends Observable implements MediaQueryList { | |
| } | ||
|
|
||
| // @ts-ignore | ||
| public addEventListener(eventName: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean): void { | ||
| public addEventListener(eventName: string, callback: (data: EventData) => void, thisArg?: any, once?: boolean): this { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| this._throwInvocationError?.(); | ||
|
|
||
| const hasChangeListeners = this.hasListeners(MediaQueryListImpl.changeEvent); | ||
|
|
@@ -124,10 +124,12 @@ class MediaQueryListImpl extends Observable implements MediaQueryList { | |
| toggleApplicationEventListeners(true, onDeviceChange); | ||
| } | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
| // @ts-ignore | ||
| public removeEventListener(eventName: string, callback?: (data: EventData) => void, thisArg?: any): void { | ||
| public removeEventListener(eventName: string, callback?: (data: EventData) => void, thisArg?: any): this { | ||
| this._throwInvocationError?.(); | ||
|
|
||
| // Call super method first since it throws in the case of bad parameters | ||
|
|
@@ -147,6 +149,8 @@ class MediaQueryListImpl extends Observable implements MediaQueryList { | |
| } | ||
| } | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
| addListener(callback: (this: MediaQueryList, ev: MediaQueryListEvent) => any): 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.
Script executed:
Repository: NativeScript/NativeScript
Length of output: 25903
Script executed:
Repository: NativeScript/NativeScript
Length of output: 41344
Script executed:
Repository: NativeScript/NativeScript
Length of output: 29876
Script executed:
Repository: NativeScript/NativeScript
Length of output: 29876
Script executed:
Repository: NativeScript/NativeScript
Length of output: 44157
Return the receiver from
SharedTransitionObservable.on.SharedTransition.events().on(...)returnsundefinedbecause the override discards the superclass result. A JavaScript chain then throws, and TypeScript callers cannot chain throughon. Returnsuper.on(eventNames, <any>callback, thisArg)from the override.