fix: downstream types and arg-passing

This commit is contained in:
shirakaba
2022-11-23 12:24:08 +09:00
parent 453adef5fa
commit 3dad494136
28 changed files with 144 additions and 127 deletions

View File

@@ -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;

View File

@@ -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.

View File

@@ -187,14 +187,15 @@ export interface VirtualArray<T> {
* @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<T>) => void, thisArg?: any): void;
on(event: 'change', callback: (args: ChangedData<T>) => void, thisArg?: any, options?: AddEventListenerOptions | boolean): void;
}

View File

@@ -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
/**

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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--) {

View File

@@ -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;
}
/**

View File

@@ -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;
}

View File

@@ -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
/**

View File

@@ -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<KeyedTemplate>;
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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}

View File

@@ -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;
}
/**

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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<CoreTypes.OrientationType>(makeValidator(CoreTypes.Orientation.horizontal, CoreTypes.Orientation.vertical));

View File

@@ -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.

View File

@@ -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.

View File

@@ -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';

View File

@@ -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<TabView, TabViewItem[]>;

View File

@@ -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) {

View File

@@ -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));
}

View File

@@ -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;
}
/**

View File

@@ -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);