fix: global types

This commit is contained in:
shirakaba
2022-11-23 13:14:48 +09:00
parent 832595281f
commit 453adef5fa
2 changed files with 6 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ import '../globals';
// Types
import { AndroidApplication, iOSApplication } from '.';
import { CssChangedEventData, DiscardedErrorEventData, LoadAppCSSEventData, UnhandledErrorEventData } from './application-interfaces';
import { EventData } from '../data/observable';
import type { EventData, Observable } from '../data/observable';
import { View } from '../ui/core/view';
// Requires
@@ -50,10 +50,10 @@ export function setResources(res: any) {
export const android: AndroidApplication = undefined;
export const ios: iOSApplication = undefined;
export const on = global.NativeScriptGlobals.events.on.bind(global.NativeScriptGlobals.events);
export const off = global.NativeScriptGlobals.events.off.bind(global.NativeScriptGlobals.events);
export const notify = global.NativeScriptGlobals.events.notify.bind(global.NativeScriptGlobals.events);
export const hasListeners = global.NativeScriptGlobals.events.hasListeners.bind(global.NativeScriptGlobals.events);
export const on = global.NativeScriptGlobals.events.on.bind(global.NativeScriptGlobals.events) as Observable['on'];
export const off = global.NativeScriptGlobals.events.off.bind(global.NativeScriptGlobals.events) as Observable['off'];
export const notify = global.NativeScriptGlobals.events.notify.bind(global.NativeScriptGlobals.events) as Observable['notify'];
export const hasListeners = global.NativeScriptGlobals.events.hasListeners.bind(global.NativeScriptGlobals.events) as Observable['hasListeners'];
let app: iOSApplication | AndroidApplication;
export function setApplication(instance: iOSApplication | AndroidApplication): void {

View File

@@ -25,17 +25,7 @@ declare namespace NodeJS {
* Global framework event handling
*/
events: {
on(eventNames: string, callback: (data: any) => void, thisArg?: any);
on(event: 'propertyChange', callback: (data: any) => void, thisArg?: any);
off(eventNames: string, callback?: any, thisArg?: any);
addEventListener(eventNames: string, callback: (data: any) => void, thisArg?: any);
removeEventListener(eventNames: string, callback?: any, thisArg?: any);
set(name: string, value: any): void;
setProperty(name: string, value: any): void;
get(name: string): any;
notify<T>(data: any): void;
notifyPropertyChange(propertyName: string, value: any, oldValue?: any): void;
hasListeners(eventName: string): boolean;
[Key in keyof import('data/observable').Observable]: import('data/observable').Observable[Key];
};
launched: boolean;
// used by various classes to setup callbacks to wire up global app event handling when the app instance is ready