@itwin/core-frontend
Version:
iTwin.js frontend components
92 lines • 4.67 kB
TypeScript
/** @packageDocumentation
* @module Tiles
*/
import { ImageSource } from "@itwin/core-common";
import { Viewport } from "../Viewport";
import { ReadonlyTileUserSet, Tile, TileContent, TileRequestChannel, TileTree, TileUser } from "./internal";
/** Represents a pending or active request to load the contents of a [[Tile]]. The request coordinates with the [[Tile.requestContent]] to obtain the raw content and
* [[Tile.readContent]] to convert the result into a [[RenderGraphic]]. TileRequests are created internally as needed; it is never necessary or useful for external code to create them.
* @public
* @extensions
*/
export declare class TileRequest {
/** The requested tile. While the request is pending or active, `tile.request` points back to this TileRequest. */
readonly tile: Tile;
/** The channel via which the request will be executed. */
readonly channel: TileRequestChannel;
/** The set of [[TileUser]]s that are awaiting the result of this request. When this becomes empty, the request is canceled because no user cares about it.
* @internal
*/
users: ReadonlyTileUserSet;
private _state;
/** Determines the order in which pending requests are pulled off the queue to become active. A tile with a lower priority value takes precedence over one with a higher value. */
priority: number;
/** Constructor */
constructor(tile: Tile, user: TileUser);
/** The set of [[Viewport]]s that are awaiting the result of this request. When this becomes empty, the request is canceled because no user cares about it. */
get viewports(): Iterable<Viewport>;
/** The request's current state. */
get state(): TileRequest.State;
/** True if the request has been enqueued but not yet dispatched. */
get isQueued(): boolean;
/** True if the request has been canceled. */
get isCanceled(): boolean;
/** The tile tree to which the requested [[Tile]] belongs. */
get tree(): TileTree;
/** Indicate that the specified user is awaiting the result of this request.
* @internal
*/
addUser(user: TileUser): void;
/** Transition the request from "queued" to "active", kicking off a series of asynchronous operations usually beginning with an http request, and -
* if the request is not subsequently canceled - resulting in either a successfully-loaded Tile, or a failed ("not found") Tile.
* @internal
*/
dispatch(onHttpResponse: () => void): Promise<void>;
/** Cancels this request. This leaves the associated Tile's state untouched.
* @internal
*/
cancel(): void;
/** Invalidates the scene of each [[TileUser]] interested in this request - typically because the request succeeded, failed, or was canceled. */
private notify;
/** Invalidates the scene of each [[TileUser]] interested in this request and clears the set of interested users. */
private notifyAndClear;
private setFailed;
/** Invoked when the raw tile content becomes available, to convert it into a tile graphic. */
private handleResponse;
}
/** @public */
export declare namespace TileRequest {
/** The type of a raw response to a request for tile content. Processed upon receipt into a [[TileRequest.Response]] type.
* [[Tile.requestContent]] produces a response of this type; it is then converted to a [[Tile.ResponseData]] from which [[Tile.readContent]]
* can produce a [[RenderGraphic]].
* @public
*/
type Response = Uint8Array | ArrayBuffer | string | ImageSource | {
content: TileContent;
} | {
data: any;
} | undefined;
/** The input to [[Tile.readContent]], to be converted into a [[RenderGraphic]].
* @public
*/
type ResponseData = Uint8Array | ImageSource | {
data: any;
};
/** The states through which a [[TileRequest]] proceeds. During the first 3 states, the [[Tile]]'s `request` member is defined,
* and its [[Tile.LoadStatus]] is computed based on the state of its request.
*@ public
*/
enum State {
/** Initial state. Request is pending but not yet dispatched. */
Queued = 0,
/** Follows `Queued` when request begins to be actively processed. */
Dispatched = 1,
/** Follows `Dispatched` when the response to the request is being converted into tile graphics. */
Loading = 2,
/** Follows `Loading` when tile graphic has successfully been produced. */
Completed = 3,
/** Follows any state in which an error prevents progression, or during which the request was canceled. */
Failed = 4
}
}
//# sourceMappingURL=TileRequest.d.ts.map