From 3dad49413601c1c8f49e5742eb8e6a7c313d53c6 Mon Sep 17 00:00:00 2001 From: shirakaba <14055146+shirakaba@users.noreply.github.com> Date: Wed, 23 Nov 2022 12:24:08 +0900 Subject: [PATCH] fix: downstream types and arg-passing --- packages/core/application/index.android.ts | 24 +++---- packages/core/application/index.d.ts | 62 ++++++++++--------- packages/core/data/virtual-array/index.ts | 7 ++- packages/core/ui/action-bar/index.d.ts | 5 +- packages/core/ui/button/index.d.ts | 5 +- packages/core/ui/core/view/index.android.ts | 2 +- .../ui/core/weak-event-listener/index.d.ts | 6 +- .../core/ui/core/weak-event-listener/index.ts | 14 ++--- packages/core/ui/frame/index.d.ts | 7 ++- .../core/ui/image-cache/image-cache-common.ts | 10 +-- packages/core/ui/image-cache/index.d.ts | 7 ++- packages/core/ui/list-view/index.d.ts | 13 ++-- .../core/ui/list-view/list-view-common.ts | 8 +-- packages/core/ui/page/index.d.ts | 11 ++-- packages/core/ui/page/page-common.ts | 14 ++--- packages/core/ui/placeholder/index.android.ts | 4 +- packages/core/ui/placeholder/index.d.ts | 5 +- packages/core/ui/placeholder/index.ts | 4 +- packages/core/ui/scroll-view/index.d.ts | 5 +- .../core/ui/scroll-view/scroll-view-common.ts | 12 ++-- packages/core/ui/search-bar/index.d.ts | 7 ++- packages/core/ui/segmented-bar/index.d.ts | 5 +- .../ui/segmented-bar/segmented-bar-common.ts | 4 +- packages/core/ui/tab-view/index.d.ts | 5 +- packages/core/ui/tab-view/tab-view-common.ts | 4 +- packages/core/ui/text-base/span.ts | 8 +-- packages/core/ui/web-view/index.d.ts | 7 ++- packages/core/ui/web-view/web-view-common.ts | 6 +- 28 files changed, 144 insertions(+), 127 deletions(-) diff --git a/packages/core/application/index.android.ts b/packages/core/application/index.android.ts index 99eecd608..f02dfbbeb 100644 --- a/packages/core/application/index.android.ts +++ b/packages/core/application/index.android.ts @@ -163,18 +163,18 @@ export class AndroidApplication extends Observable implements AndroidApplication // HACK: We declare all these 'on' statements, so that they can appear in the API reference // HACK: Do we need this? Is it useful? There are static fields to the AndroidApplication class for the event names. export interface AndroidApplication { - on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); - on(event: 'activityCreated', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); - on(event: 'activityDestroyed', callback: (args: AndroidActivityEventData) => void, thisArg?: any); - on(event: 'activityStarted', callback: (args: AndroidActivityEventData) => void, thisArg?: any); - on(event: 'activityPaused', callback: (args: AndroidActivityEventData) => void, thisArg?: any); - on(event: 'activityResumed', callback: (args: AndroidActivityEventData) => void, thisArg?: any); - on(event: 'activityStopped', callback: (args: AndroidActivityEventData) => void, thisArg?: any); - on(event: 'saveActivityState', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); - on(event: 'activityResult', callback: (args: AndroidActivityResultEventData) => void, thisArg?: any); - on(event: 'activityBackPressed', callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any); - on(event: 'activityNewIntent', callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any); - on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityCreated', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityDestroyed', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityStarted', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityPaused', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityResumed', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityStopped', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'saveActivityState', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityResult', callback: (args: AndroidActivityResultEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityBackPressed', callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityNewIntent', callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } let androidApp: AndroidApplication; diff --git a/packages/core/application/index.d.ts b/packages/core/application/index.d.ts index 646399a0d..32da82403 100644 --- a/packages/core/application/index.d.ts +++ b/packages/core/application/index.d.ts @@ -257,15 +257,16 @@ export function _resetRootView(entry?: NavigationEntry | string); /** * Removes listener for the specified event name. */ -export function off(eventNames: string, callback?: any, thisArg?: any); +export function off(eventNames: string, callback?: (eventData: EventData) => void, thisArg?: any, options?: EventListenerOptions | boolean): void; /** * Shortcut alias to the removeEventListener method. * @param eventNames - String corresponding to events (e.g. "onLaunch"). * @param callback - Callback function which will be removed. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ -export function off(eventNames: string, callback?: any, thisArg?: any); +export function off(eventNames: string, callback?: (eventData: EventData) => void, thisArg?: any, options?: EventListenerOptions | boolean): void; /** * Notifies all the registered listeners for the event provided in the data.eventName. @@ -284,84 +285,85 @@ export function hasListeners(eventName: string): boolean; * @param eventNames - String corresponding to events (e.g. "onLaunch"). Optionally could be used more events separated by `,` (e.g. "onLaunch", "onSuspend"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ -export function on(eventNames: string, callback: (data: any) => void, thisArg?: any); +export function on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when application css is changed. */ -export function on(event: 'cssChanged', callback: (args: CssChangedEventData) => void, thisArg?: any); +export function on(event: 'cssChanged', callback: (args: CssChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Event raised then livesync operation is performed. */ -export function on(event: 'livesync', callback: (args: EventData) => void); +export function on(event: 'livesync', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when application css is changed. */ -export function on(event: 'cssChanged', callback: (args: CssChangedEventData) => void, thisArg?: any); +export function on(event: 'cssChanged', callback: (args: CssChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Event raised then livesync operation is performed. */ -export function on(event: 'livesync', callback: (args: EventData) => void); +export function on(event: 'livesync', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on application launchEvent. */ -export function on(event: 'launch', callback: (args: LaunchEventData) => void, thisArg?: any); +export function on(event: 'launch', callback: (args: LaunchEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised after the application has performed most of its startup actions. * Its intent is to be suitable for measuring app startup times. * @experimental */ -export function on(event: 'displayed', callback: (args: EventData) => void, thisArg?: any); +export function on(event: 'displayed', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the Application is suspended. */ -export function on(event: 'suspend', callback: (args: ApplicationEventData) => void, thisArg?: any); +export function on(event: 'suspend', callback: (args: ApplicationEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the Application is resumed after it has been suspended. */ -export function on(event: 'resume', callback: (args: ApplicationEventData) => void, thisArg?: any); +export function on(event: 'resume', callback: (args: ApplicationEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the Application is about to exit. */ -export function on(event: 'exit', callback: (args: ApplicationEventData) => void, thisArg?: any); +export function on(event: 'exit', callback: (args: ApplicationEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when there is low memory on the target device. */ -export function on(event: 'lowMemory', callback: (args: ApplicationEventData) => void, thisArg?: any); +export function on(event: 'lowMemory', callback: (args: ApplicationEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when an uncaught error occurs while the application is running. */ -export function on(event: 'uncaughtError', callback: (args: UnhandledErrorEventData) => void, thisArg?: any); +export function on(event: 'uncaughtError', callback: (args: UnhandledErrorEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when an discarded error occurs while the application is running. */ -export function on(event: 'discardedError', callback: (args: DiscardedErrorEventData) => void, thisArg?: any); +export function on(event: 'discardedError', callback: (args: DiscardedErrorEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the orientation of the application changes. */ -export function on(event: 'orientationChanged', callback: (args: OrientationChangedEventData) => void, thisArg?: any); +export function on(event: 'orientationChanged', callback: (args: OrientationChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the operating system appearance changes * between light and dark theme (for Android); * between light and dark mode (for iOS) and vice versa. */ -export function on(event: 'systemAppearanceChanged', callback: (args: SystemAppearanceChangedEventData) => void, thisArg?: any); +export function on(event: 'systemAppearanceChanged', callback: (args: SystemAppearanceChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; -export function on(event: 'fontScaleChanged', callback: (args: FontScaleChangedEventData) => void, thisArg?: any); +export function on(event: 'fontScaleChanged', callback: (args: FontScaleChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Gets the orientation of the application. @@ -553,62 +555,62 @@ export class AndroidApplication extends Observable { * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. */ - on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityCreated. */ - on(event: 'activityCreated', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + on(event: 'activityCreated', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityDestroyed. */ - on(event: 'activityDestroyed', callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: 'activityDestroyed', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityStarted. */ - on(event: 'activityStarted', callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: 'activityStarted', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityPaused. */ - on(event: 'activityPaused', callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: 'activityPaused', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityResumed. */ - on(event: 'activityResumed', callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: 'activityResumed', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityStopped. */ - on(event: 'activityStopped', callback: (args: AndroidActivityEventData) => void, thisArg?: any); + on(event: 'activityStopped', callback: (args: AndroidActivityEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application SaveActivityState. */ - on(event: 'saveActivityState', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + on(event: 'saveActivityState', callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on android application ActivityResult. */ - on(event: 'activityResult', callback: (args: AndroidActivityResultEventData) => void, thisArg?: any); + on(event: 'activityResult', callback: (args: AndroidActivityResultEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised on the back button is pressed in an android application. */ - on(event: 'activityBackPressed', callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any); + on(event: 'activityBackPressed', callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the Android app was launched by an Intent with data. */ - on(event: 'activityNewIntent', callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any); + on(event: 'activityNewIntent', callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * This event is raised when the Android activity requests permissions. */ - on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any); + on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * String value used when hooking to activityCreated event. diff --git a/packages/core/data/virtual-array/index.ts b/packages/core/data/virtual-array/index.ts index bf16e4728..9fc4e911c 100644 --- a/packages/core/data/virtual-array/index.ts +++ b/packages/core/data/virtual-array/index.ts @@ -187,14 +187,15 @@ export interface VirtualArray { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when still not loaded items are requested. */ - on(event: 'itemsLoading', callback: (args: ItemsLoading) => void, thisArg?: any): void; + on(event: 'itemsLoading', callback: (args: ItemsLoading) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a change occurs. */ - on(event: 'change', callback: (args: ChangedData) => void, thisArg?: any): void; + on(event: 'change', callback: (args: ChangedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } diff --git a/packages/core/ui/action-bar/index.d.ts b/packages/core/ui/action-bar/index.d.ts index 89484c5a1..7cd84d5c8 100644 --- a/packages/core/ui/action-bar/index.d.ts +++ b/packages/core/ui/action-bar/index.d.ts @@ -133,13 +133,14 @@ export class ActionItem extends ViewBase { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void); + on(eventNames: string, callback: (data: EventData) => void, options?: AddEventListenerOptions | boolean): void; /** * Raised when a tap event occurs. */ - on(event: 'tap', callback: (args: EventData) => void); + on(event: 'tap', callback: (args: EventData) => void, options?: AddEventListenerOptions | boolean): void; //@private /** diff --git a/packages/core/ui/button/index.d.ts b/packages/core/ui/button/index.d.ts index 8560e1b68..b60976133 100644 --- a/packages/core/ui/button/index.d.ts +++ b/packages/core/ui/button/index.d.ts @@ -30,11 +30,12 @@ export class Button extends TextBase { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a tap event occurs. */ - on(event: 'tap', callback: (args: EventData) => void, thisArg?: any); + on(event: 'tap', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } diff --git a/packages/core/ui/core/view/index.android.ts b/packages/core/ui/core/view/index.android.ts index bb3b88ea1..81978d870 100644 --- a/packages/core/ui/core/view/index.android.ts +++ b/packages/core/ui/core/view/index.android.ts @@ -360,7 +360,7 @@ export class View extends ViewCommon { } } - off(eventNames: string, callback?: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void { + off(eventNames: string, callback?: (data: EventData) => void, thisArg?: any, options?: EventListenerOptions | boolean): void { super.off(eventNames, callback, thisArg, options); const isLayoutEvent = typeof eventNames === 'string' ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false; diff --git a/packages/core/ui/core/weak-event-listener/index.d.ts b/packages/core/ui/core/weak-event-listener/index.d.ts index 3ddf01947..547824ea9 100644 --- a/packages/core/ui/core/weak-event-listener/index.d.ts +++ b/packages/core/ui/core/weak-event-listener/index.d.ts @@ -6,8 +6,9 @@ import { Observable, EventData } from '../../../data/observable'; * @param eventName The event name. * @param handler The function which should be called when event occurs. * @param target Subscriber (target) of the event listener. It will be used as a thisArg in the handler function. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ -export function addWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any): void; +export function addWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any, options?: AddEventListenerOptions | boolean): void; /** * Removes a WeakEventListener. @@ -15,5 +16,6 @@ export function addWeakEventListener(source: Observable, eventName: string, hand * @param eventName The event name. * @param handler The function which should be called when event occurs. * @param target Subscriber (target) of the event listener. It will be used as a thisArg in the handler function. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ -export function removeWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any): void; +export function removeWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any, options?: AddEventListenerOptions | boolean): void; diff --git a/packages/core/ui/core/weak-event-listener/index.ts b/packages/core/ui/core/weak-event-listener/index.ts index 21a34ebcc..7b419826a 100644 --- a/packages/core/ui/core/weak-event-listener/index.ts +++ b/packages/core/ui/core/weak-event-listener/index.ts @@ -78,7 +78,7 @@ function validateArgs(source: Observable, eventName: string, handler: (eventData } } -export function addWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any) { +export function addWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any, options?: AddEventListenerOptions | boolean): void { validateArgs(source, eventName, handler, target); let shouldAttach = false; @@ -100,11 +100,11 @@ export function addWeakEventListener(source: Observable, eventName: string, hand pairList.push(new TargetHandlerPair(target, handler)); if (shouldAttach) { - source.addEventListener(eventName, getHandlerForEventName(eventName)); + source.addEventListener(eventName, getHandlerForEventName(eventName), options); } } -export function removeWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any) { +export function removeWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any, options?: AddEventListenerOptions | boolean): void { validateArgs(source, eventName, handler, target); const handlerForEventWithName = handlersForEventName.get(eventName); @@ -124,9 +124,9 @@ export function removeWeakEventListener(source: Observable, eventName: string, h } // Remove all pairs that match given target and handler or have a dead target - const targetHandlerPairsToRemove = []; - let pair; - let registeredTarget; + const targetHandlerPairsToRemove: number[] = []; + let pair: TargetHandlerPair; + let registeredTarget: Object; for (let i = 0; i < targetHandlerPairList.length; i++) { pair = targetHandlerPairList[i]; @@ -138,7 +138,7 @@ export function removeWeakEventListener(source: Observable, eventName: string, h if (targetHandlerPairsToRemove.length === targetHandlerPairList.length) { // There are no alive targets for this event - unsubscribe - source.removeEventListener(eventName, handlerForEventWithName); + source.removeEventListener(eventName, handlerForEventWithName, options); sourceEventMap.delete(eventName); } else { for (let j = targetHandlerPairsToRemove.length - 1; j >= 0; j--) { diff --git a/packages/core/ui/frame/index.d.ts b/packages/core/ui/frame/index.d.ts index e541f4040..ba0fe0c64 100644 --- a/packages/core/ui/frame/index.d.ts +++ b/packages/core/ui/frame/index.d.ts @@ -220,18 +220,19 @@ export class Frame extends FrameBase { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (args: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when navigation to the page has started. */ - public on(event: 'navigatingTo', callback: (args: NavigationData) => void, thisArg?: any); + public on(event: 'navigatingTo', callback: (args: NavigationData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when navigation to the page has finished. */ - public on(event: 'navigatedTo', callback: (args: NavigationData) => void, thisArg?: any); + public on(event: 'navigatedTo', callback: (args: NavigationData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } /** diff --git a/packages/core/ui/image-cache/image-cache-common.ts b/packages/core/ui/image-cache/image-cache-common.ts index 7dfb0c7e0..5d5dfd627 100644 --- a/packages/core/ui/image-cache/image-cache-common.ts +++ b/packages/core/ui/image-cache/image-cache-common.ts @@ -1,5 +1,5 @@ import * as definition from '.'; -import * as observable from '../../data/observable'; +import { EventData, Observable } from '../../data/observable'; import * as imageSource from '../../image-source'; export interface DownloadRequest { @@ -9,7 +9,7 @@ export interface DownloadRequest { error?: (key: string) => void; } -export class Cache extends observable.Observable implements definition.Cache { +export class Cache extends Observable implements definition.Cache { public static downloadedEvent = 'downloaded'; public static downloadErrorEvent = 'downloadError'; @@ -215,7 +215,7 @@ export class Cache extends observable.Observable implements definition.Cache { } } export interface Cache { - on(eventNames: string, callback: (args: observable.EventData) => void, thisArg?: any); - on(event: 'downloaded', callback: (args: definition.DownloadedData) => void, thisArg?: any); - on(event: 'downloadError', callback: (args: definition.DownloadError) => void, thisArg?: any); + on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'downloaded', callback: (args: definition.DownloadedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'downloadError', callback: (args: definition.DownloadError) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } diff --git a/packages/core/ui/image-cache/index.d.ts b/packages/core/ui/image-cache/index.d.ts index 5bb06ad36..41146ea0d 100644 --- a/packages/core/ui/image-cache/index.d.ts +++ b/packages/core/ui/image-cache/index.d.ts @@ -84,18 +84,19 @@ export class Cache extends Observable { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (args: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when the image has been downloaded. */ - on(event: 'downloaded', callback: (args: DownloadedData) => void, thisArg?: any); + on(event: 'downloaded', callback: (args: DownloadedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised if the image download errors. */ - on(event: 'downloadError', callback: (args: DownloadError) => void, thisArg?: any); + on(event: 'downloadError', callback: (args: DownloadError) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; //@private /** diff --git a/packages/core/ui/list-view/index.d.ts b/packages/core/ui/list-view/index.d.ts index e1e6d85d8..7faad0029 100644 --- a/packages/core/ui/list-view/index.d.ts +++ b/packages/core/ui/list-view/index.d.ts @@ -107,8 +107,9 @@ export class ListView extends View { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a View for the data at the specified index should be created. @@ -116,17 +117,17 @@ export class ListView extends View { * Note, that the view property of the event data can be pre-initialized with * an old instance of a view, so that it can be reused. */ - on(event: 'itemLoading', callback: (args: ItemEventData) => void, thisArg?: any); + on(event: 'itemLoading', callback: (args: ItemEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when an item inside the ListView is tapped. */ - on(event: 'itemTap', callback: (args: ItemEventData) => void, thisArg?: any); + on(event: 'itemTap', callback: (args: ItemEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when the ListView is scrolled so that its last item is visible. */ - on(event: 'loadMoreItems', callback: (args: EventData) => void, thisArg?: any); + on(event: 'loadMoreItems', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } /** @@ -164,8 +165,8 @@ export interface TemplatedItemsView { itemTemplate: string | Template; itemTemplates?: string | Array; refresh(): void; - on(event: 'itemLoading', callback: (args: ItemEventData) => void, thisArg?: any); - off(event: 'itemLoading', callback: (args: EventData) => void, thisArg?: any); + on(event: 'itemLoading', callback: (args: ItemEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + off(event: 'itemLoading', callback: (args: EventData) => void, thisArg?: any, options?: EventListenerOptions | boolean): void; } /** diff --git a/packages/core/ui/list-view/list-view-common.ts b/packages/core/ui/list-view/list-view-common.ts index 25180a78f..9289c8293 100644 --- a/packages/core/ui/list-view/list-view-common.ts +++ b/packages/core/ui/list-view/list-view-common.ts @@ -154,10 +154,10 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi ListViewBase.prototype.recycleNativeView = 'auto'; export interface ListViewBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; - on(event: 'itemLoading', callback: (args: ItemEventData) => void, thisArg?: any): void; - on(event: 'itemTap', callback: (args: ItemEventData) => void, thisArg?: any): void; - on(event: 'loadMoreItems', callback: (args: EventData) => void, thisArg?: any): void; + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'itemLoading', callback: (args: ItemEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'itemTap', callback: (args: ItemEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'loadMoreItems', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } /** diff --git a/packages/core/ui/page/index.d.ts b/packages/core/ui/page/index.d.ts index b7ca04647..c575b5da2 100644 --- a/packages/core/ui/page/index.d.ts +++ b/packages/core/ui/page/index.d.ts @@ -115,28 +115,29 @@ export declare class Page extends PageBase { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; + public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when navigation to the page has started. */ - public on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any): void; + public on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when navigation to the page has finished. */ - public on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any): void; + public on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when navigation from the page has started. */ - public on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any): void; + public on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when navigation from the page has finished. */ - public on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any): void; + public on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; //@private /** diff --git a/packages/core/ui/page/page-common.ts b/packages/core/ui/page/page-common.ts index 6bfb4b122..b237b00ab 100644 --- a/packages/core/ui/page/page-common.ts +++ b/packages/core/ui/page/page-common.ts @@ -166,13 +166,13 @@ export class PageBase extends ContentView { PageBase.prototype.recycleNativeView = 'never'; export interface PageBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; - on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any): void; - on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any): void; - on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any): void; - on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any): void; - on(event: 'showingModally', callback: (args: ShownModallyData) => void, thisArg?: any): void; - on(event: 'shownModally', callback: (args: ShownModallyData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'showingModally', callback: (args: ShownModallyData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'shownModally', callback: (args: ShownModallyData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } /** diff --git a/packages/core/ui/placeholder/index.android.ts b/packages/core/ui/placeholder/index.android.ts index 9bafa34f5..43250a3c2 100644 --- a/packages/core/ui/placeholder/index.android.ts +++ b/packages/core/ui/placeholder/index.android.ts @@ -21,6 +21,6 @@ export class Placeholder extends View { } } export interface Placeholder { - on(eventNames: string, callback: (args: EventData) => void); - on(event: 'creatingView', callback: (args: CreateViewEventData) => void); + on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'creatingView', callback: (args: CreateViewEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } diff --git a/packages/core/ui/placeholder/index.d.ts b/packages/core/ui/placeholder/index.d.ts index a2268c9a1..61de79854 100644 --- a/packages/core/ui/placeholder/index.d.ts +++ b/packages/core/ui/placeholder/index.d.ts @@ -17,13 +17,14 @@ export class Placeholder extends View { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (args: EventData) => void); + on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a creatingView event occurs. */ - on(event: 'creatingView', callback: (args: CreateViewEventData) => void); + on(event: 'creatingView', callback: (args: CreateViewEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } /** diff --git a/packages/core/ui/placeholder/index.ts b/packages/core/ui/placeholder/index.ts index 2d6c5f05d..3c43046ab 100644 --- a/packages/core/ui/placeholder/index.ts +++ b/packages/core/ui/placeholder/index.ts @@ -20,6 +20,6 @@ export class Placeholder extends View { } } export interface Placeholder { - on(eventNames: string, callback: (args: EventData) => void); - on(event: 'creatingView', callback: (args: CreateViewEventData) => void); + on(eventNames: string, callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'creatingView', callback: (args: CreateViewEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } diff --git a/packages/core/ui/scroll-view/index.d.ts b/packages/core/ui/scroll-view/index.d.ts index a6176a381..127038532 100644 --- a/packages/core/ui/scroll-view/index.d.ts +++ b/packages/core/ui/scroll-view/index.d.ts @@ -66,13 +66,14 @@ export class ScrollView extends ContentView { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a scroll event occurs. */ - on(event: 'scroll', callback: (args: ScrollEventData) => void, thisArg?: any): void; + on(event: 'scroll', callback: (args: ScrollEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; _onOrientationChanged(): void; } diff --git a/packages/core/ui/scroll-view/scroll-view-common.ts b/packages/core/ui/scroll-view/scroll-view-common.ts index 774d05b56..cda090261 100644 --- a/packages/core/ui/scroll-view/scroll-view-common.ts +++ b/packages/core/ui/scroll-view/scroll-view-common.ts @@ -16,8 +16,8 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe public scrollBarIndicatorVisible: boolean; public isScrollEnabled: boolean; - public addEventListener(arg: string, callback: any, thisArg?: any) { - super.addEventListener(arg, callback, thisArg); + public addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void { + super.addEventListener(arg, callback, thisArg, options); if (arg === ScrollViewBase.scrollEvent) { this._scrollChangeCount++; @@ -25,8 +25,8 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe } } - public removeEventListener(arg: string, callback: any, thisArg?: any) { - super.removeEventListener(arg, callback, thisArg); + public removeEventListener(arg: string, callback?: (data: EventData) => void, thisArg?: any, options?: EventListenerOptions | boolean): void { + super.removeEventListener(arg, callback, thisArg, options); if (arg === ScrollViewBase.scrollEvent) { this._scrollChangeCount--; @@ -87,8 +87,8 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe public abstract _onOrientationChanged(); } export interface ScrollViewBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: 'scroll', callback: (args: ScrollEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'scroll', callback: (args: ScrollEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } const converter = makeParser(makeValidator(CoreTypes.Orientation.horizontal, CoreTypes.Orientation.vertical)); diff --git a/packages/core/ui/search-bar/index.d.ts b/packages/core/ui/search-bar/index.d.ts index 6283c5c20..5befdaef6 100644 --- a/packages/core/ui/search-bar/index.d.ts +++ b/packages/core/ui/search-bar/index.d.ts @@ -52,18 +52,19 @@ export class SearchBar extends View { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a search bar search is submitted. */ - on(event: 'submit', callback: (args: EventData) => void, thisArg?: any); + on(event: 'submit', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a search bar search is closed. */ - on(event: 'close', callback: (args: EventData) => void, thisArg?: any); + on(event: 'close', callback: (args: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Hides the soft input method, usually a soft keyboard. diff --git a/packages/core/ui/segmented-bar/index.d.ts b/packages/core/ui/segmented-bar/index.d.ts index b3d0ed4e9..7b7de1a88 100644 --- a/packages/core/ui/segmented-bar/index.d.ts +++ b/packages/core/ui/segmented-bar/index.d.ts @@ -59,13 +59,14 @@ export class SegmentedBar extends View implements AddChildFromBuilder, AddArrayF * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when the selected index changes. */ - on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Called for every child element declared in xml. diff --git a/packages/core/ui/segmented-bar/segmented-bar-common.ts b/packages/core/ui/segmented-bar/segmented-bar-common.ts index 17026a3dd..63381ea30 100644 --- a/packages/core/ui/segmented-bar/segmented-bar-common.ts +++ b/packages/core/ui/segmented-bar/segmented-bar-common.ts @@ -89,8 +89,8 @@ export abstract class SegmentedBarBase extends View implements SegmentedBarDefin } export interface SegmentedBarBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } SegmentedBarBase.prototype.recycleNativeView = 'auto'; diff --git a/packages/core/ui/tab-view/index.d.ts b/packages/core/ui/tab-view/index.d.ts index 8d65abe7c..08f2f28d1 100644 --- a/packages/core/ui/tab-view/index.d.ts +++ b/packages/core/ui/tab-view/index.d.ts @@ -149,13 +149,14 @@ export class TabView extends View { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when the selected index changes. */ - on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } export const itemsProperty: Property; diff --git a/packages/core/ui/tab-view/tab-view-common.ts b/packages/core/ui/tab-view/tab-view-common.ts index f2c880ffb..7756933c3 100644 --- a/packages/core/ui/tab-view/tab-view-common.ts +++ b/packages/core/ui/tab-view/tab-view-common.ts @@ -205,8 +205,8 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom } export interface TabViewBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'selectedIndexChanged', callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } export function traceMissingIcon(icon: string) { diff --git a/packages/core/ui/text-base/span.ts b/packages/core/ui/text-base/span.ts index 84bbfe7ae..734519606 100644 --- a/packages/core/ui/text-base/span.ts +++ b/packages/core/ui/text-base/span.ts @@ -81,13 +81,13 @@ export class Span extends ViewBase implements SpanDefinition { return this._tappable; } - addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any) { - super.addEventListener(arg, callback, thisArg); + addEventListener(arg: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void { + super.addEventListener(arg, callback, thisArg, options); this._setTappable(this.hasListeners(Span.linkTapEvent)); } - removeEventListener(arg: string, callback?: any, thisArg?: any) { - super.removeEventListener(arg, callback, thisArg); + removeEventListener(arg: string, callback?: (data: EventData) => void, thisArg?: any, options?: EventListenerOptions | boolean): void { + super.removeEventListener(arg, callback, thisArg, options); this._setTappable(this.hasListeners(Span.linkTapEvent)); } diff --git a/packages/core/ui/web-view/index.d.ts b/packages/core/ui/web-view/index.d.ts index 9cd128b47..da32c5078 100644 --- a/packages/core/ui/web-view/index.d.ts +++ b/packages/core/ui/web-view/index.d.ts @@ -91,18 +91,19 @@ export class WebView extends View { * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). * @param callback - Callback function which will be executed when event is raised. * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + * @param options An optional parameter. If passed as a boolean, configures the useCapture value. Otherwise, specifies options. */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a loadFinished event occurs. */ - on(event: 'loadFinished', callback: (args: LoadEventData) => void, thisArg?: any); + on(event: 'loadFinished', callback: (args: LoadEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; /** * Raised when a loadStarted event occurs. */ - on(event: 'loadStarted', callback: (args: LoadEventData) => void, thisArg?: any); + on(event: 'loadStarted', callback: (args: LoadEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } /** diff --git a/packages/core/ui/web-view/web-view-common.ts b/packages/core/ui/web-view/web-view-common.ts index 9c95a6045..adc3b1401 100644 --- a/packages/core/ui/web-view/web-view-common.ts +++ b/packages/core/ui/web-view/web-view-common.ts @@ -101,9 +101,9 @@ export abstract class WebViewBase extends ContainerView { // HACK: We declare all these 'on' statements, so that they can appear in the API reference // HACK: Do we need this? Is it useful? There are static fields to the WebViewBase class for the event names. export interface WebViewBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; - on(event: 'loadFinished', callback: (args: LoadEventData) => void, thisArg?: any): void; - on(event: 'loadStarted', callback: (args: LoadEventData) => void, thisArg?: any): void; + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'loadFinished', callback: (args: LoadEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; + on(event: 'loadStarted', callback: (args: LoadEventData) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void; } srcProperty.register(WebViewBase);