From 3d1bed2f48cba3d1df96458035ff3cdf4a89b271 Mon Sep 17 00:00:00 2001 From: shreedhart Date: Fri, 4 May 2018 13:51:02 -0700 Subject: [PATCH] Adding Office.onReady() (#25518) Added declaration for Office.onReady() API. --- types/office-js/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index e08e0f1ee0..629ccacb21 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -20,6 +20,13 @@ declare namespace Office { * @param reason Indicates how the app was initialized */ export function initialize(reason: InitializationReason): void; + /** + * Ensures that the Office JavaScript APIs are ready to be called by the add-in. If the framework hasn't initialized yet, the callback or promise will wait until the Office host is ready to accept API calls. + * Note that though this API is intended to be used inside an Office add-in, it can also be used outside the add-in. In that case, once Office.js determines that it is running outside of an Office host application, it will call the callback and resolve the promise with "null" for both the host and platform. + * @param callback - An optional callback method, that will receive the host and platform info. Alternatively, rather than use a callback, an add-in may simply wait for the Promise returned by the function to resolve. + * @returns A Promise that contains the host and platform info, once initialization is completed. + */ + export function onReady(callback?: (info: { host: HostType, platform: PlatformType} ) => any): Promise<{ host: HostType, platform: PlatformType }>; /** * Indicates if the large namespace for objects will be used or not. * @param useShortNamespace Indicates if 'true' that the short namespace will be used