@eclipse-scout/core
Version:
Eclipse Scout runtime
74 lines • 3.23 kB
TypeScript
/// <reference types="jquery" />
import { BaseDoEntity, HybridActionContextElements, InitModelOf, ObjectWithType, UiCallbacksEventMap, Widget } from '../../../index';
/**
* Processes UI callback requests from the client backend.
*/
export declare class UiCallbacks extends Widget {
eventMap: UiCallbacksEventMap;
self: UiCallbacks;
onCallback(handlerObjectType: string, callbackId: string, owner: Widget, data: BaseDoEntity, contextElements: HybridActionContextElements): void;
protected _convertResult(result: any): UiCallbackResult;
protected _convertError(error: any): JQuery.Promise<UiCallbackErrorDo>;
protected _triggerCallbackEnd(callbackId: string, result: UiCallbackResult, error: UiCallbackErrorDo): void;
}
/**
* Represents the result of a successful UI callback.
*/
export declare class UiCallbackResult implements ObjectWithType, UiCallbackResultModel {
model: UiCallbackResultModel;
objectType: string;
data: BaseDoEntity | any;
contextElements: HybridActionContextElements;
init(model: InitModelOf<this>): void;
}
export interface UiCallbackResultModel {
/**
* Optional data to send back to the server. Can be either a {@link BaseDoEntity} or a {@link JsonValue}.
*/
data?: BaseDoEntity | any;
/**
* Optional {@link HybridActionContextElements context elements} to send back to the server along with the {@link #data}.
*/
contextElements?: HybridActionContextElements;
}
/**
* Represents the result of an unsuccessful UI callback.
*/
export declare class UiCallbackErrorDo extends BaseDoEntity {
message: string;
code: string;
}
/**
* Browser-side UI callback handler. Called when a corresponding `callback` event is received from the server.
* A new instance is created for each callback call.
*/
export interface UiCallbackHandler {
/**
* Called when a UI callback is requested from the server.
*
* The callback is answered with a `callbackEnd` event when the returned promise is resolved or rejected.
*
* The promise can be **resolved** with a {@link UiCallbackResult} or a {@link BaseDoEntity}. The latter will
* automatically be converted to a {@link UiCallbackResult} and is provided as a convenience for simple callback
* handlers that don't require {@link HybridActionContextElements context elements}.
*
* The promise can be **rejected** with a {@link UiCallbackErrorDo}. Anything else (including `string` and
* {@link Error}) will automatically be converted to a {@link UiCallbackErrorDo} using the application's
* {@link ErrorHandler}.
*/
handle(param: UiCallbackParam): JQuery.Promise<any>;
}
/**
* Represents the callback arguments sent from the server.
*/
export interface UiCallbackParam {
/** The ID of the callback (as sent from the server). */
callbackId: string;
/** The owner {@link Widget} the call belongs to. */
owner: Widget;
/** The optional {@link BaseDoEntity} sent from the server. May be `null`. */
data?: BaseDoEntity;
/** The optional context elements sent from the server. May be `null`. */
contextElements?: HybridActionContextElements;
}
//# sourceMappingURL=UiCallbacks.d.ts.map