UNPKG

@microsoft/teams-js

Version:

Microsoft Client SDK for building app for Microsoft hosts

31 lines (30 loc) 1.33 kB
/** * This class is used for validating and deserializing the response from the host. * * @typeParam SerializedReturnValueFromHost The type of the response received from the host * @typeParam DeserializedReturnValueFromHost The type of the response after deserialization */ export declare abstract class ResponseHandler<SerializedReturnValueFromHost, DeserializedReturnValueFromHost> { /** * Checks if the response from the host is valid. * * @param response The response from the host to validate * * @returns True if the response is valid, false otherwise */ abstract validate(response: SerializedReturnValueFromHost): boolean; /** * This function converts the response from the host into a different format * before returning it to the caller (if needed). * @param response */ abstract deserialize(response: SerializedReturnValueFromHost): DeserializedReturnValueFromHost; } export type SimpleType = string | number | boolean | null | undefined | SimpleType[]; /** * This class is used for validating and deserializing boolean responses from the host. */ export declare class SimpleTypeResponseHandler<T extends SimpleType> extends ResponseHandler<T, T> { validate(_response: T): boolean; deserialize(response: T): T; }