@microsoft/teams-js
Version:
Microsoft Client SDK for building app for Microsoft hosts
67 lines (66 loc) • 2.91 kB
TypeScript
/** onComplete function type */
export type onCompleteFunctionType = (status: boolean, reason?: string) => void;
/** addEventListner function type */
export type addEventListnerFunctionType = (message: any) => void;
/** Represents a window or frame within the host app. */
export interface IAppWindow {
/**
* Send a message to the AppWindow.
*
* @param message - The message to send
* @param onComplete - The callback to know if the postMessage has been success/failed.
*/
postMessage(message: any, onComplete?: onCompleteFunctionType): void;
/**
* Add a listener that will be called when an event is received from this AppWindow.
*
* @param type - The event to listen to. Currently the only supported type is 'message'.
* @param listener - The listener that will be called
*/
addEventListener(type: string, listener: Function): void;
}
/**
* An object that application can utilize to establish communication
* with the child window it opened, which contains the corresponding task.
*/
export declare class ChildAppWindow implements IAppWindow {
/**
* Send a message to the ChildAppWindow.
*
* @param message - The message to send
* @param onComplete - The callback to know if the postMessage has been success/failed.
*/
postMessage(message: any, onComplete?: onCompleteFunctionType): void;
/**
* Add a listener that will be called when an event is received from the ChildAppWindow.
*
* @param type - The event to listen to. Currently the only supported type is 'message'.
* @param listener - The listener that will be called
*/
addEventListener(type: string, listener: addEventListnerFunctionType): void;
}
/**
* An object that is utilized to facilitate communication with a parent window
* that initiated the opening of current window. For instance, a dialog or task
* module would utilize it to transmit messages to the application that launched it.
*/
export declare class ParentAppWindow implements IAppWindow {
/** Represents a parent window or frame. */
private static _instance;
/** Get the parent window instance. */
static get Instance(): IAppWindow;
/**
* Send a message to the ParentAppWindow.
*
* @param message - The message to send
* @param onComplete - The callback to know if the postMessage has been success/failed.
*/
postMessage(message: any, onComplete?: onCompleteFunctionType): void;
/**
* Add a listener that will be called when an event is received from the ParentAppWindow.
*
* @param type - The event to listen to. Currently the only supported type is 'message'.
* @param listener - The listener that will be called
*/
addEventListener(type: string, listener: addEventListnerFunctionType): void;
}