From 951b738dc935be4b5f31bcb92f7dfc3f863fa3d5 Mon Sep 17 00:00:00 2001 From: Manish Lakhara Date: Sat, 6 Aug 2016 21:15:34 +0530 Subject: [PATCH] Added Promise/A+ compliant thenable. Extending HelloJSEvent from HelloJSThenable. --- hellojs/hellojs.d.ts | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 7dabae4054..d831a3d836 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -18,23 +18,6 @@ interface HelloJSLogoutOptions { force?: boolean; } -interface HelloJSEvent { - on(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; - off(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; - findEvents(event: string, callback: (name: string, index: number) => void): void; - emit(event: string, data: any): HelloJSStatic; - emitAfter(): HelloJSStatic; - success(callback: (json?: any) => void): HelloJSStatic; - error(callback: (json?: any) => void): HelloJSStatic; - complete(callback: (json?: any) => void): HelloJSStatic; -} - - -interface HelloJSEventArgument { - network: string; - authResponse?: any; -} - interface HelloJSImmediateSuccessCB { (value: T): TP; } @@ -73,11 +56,28 @@ interface HelloJSThenable { ): HelloJSThenable; } +interface HelloJSEvent extends HelloJSThenable { + on(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; + off(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; + findEvents(event: string, callback: (name: string, index: number) => void): void; + emit(event: string, data: any): HelloJSStatic; + emitAfter(): HelloJSStatic; + success(callback: (json?: any) => void): HelloJSStatic; + error(callback: (json?: any) => void): HelloJSStatic; + complete(callback: (json?: any) => void): HelloJSStatic; +} + + +interface HelloJSEventArgument { + network: string; + authResponse?: any; +} + interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; - login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; + login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSStatic; + logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSStatic; getAuthResponse(network: string): any; service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; @@ -93,7 +93,7 @@ interface HelloJSStaticNamed { login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; logout(callback?: () => void): HelloJSThenable; getAuthResponse(): any; - api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; + api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSStatic; } interface HelloJSOAuthDef {