38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { type IHttpOpts, type MatrixHttpApi } from "./http-api/index.ts";
|
|
import { type Logger } from "./logger.ts";
|
|
import { TypedEventEmitter } from "./models/typed-event-emitter.ts";
|
|
/**
|
|
* Manages storing and periodically refreshing the server capabilities.
|
|
*/
|
|
export declare abstract class CapabilityPoller<ResponseType> extends TypedEventEmitter<"update", {
|
|
update: (data: ResponseType) => void;
|
|
}> {
|
|
protected readonly logger: Logger;
|
|
protected readonly http: MatrixHttpApi<IHttpOpts & {
|
|
onlyData: true;
|
|
}>;
|
|
private readonly name;
|
|
protected cached?: ResponseType;
|
|
private retryTimeout?;
|
|
private refreshTimeout?;
|
|
constructor(logger: Logger, http: MatrixHttpApi<IHttpOpts & {
|
|
onlyData: true;
|
|
}>, name: string);
|
|
/**
|
|
* Starts periodically fetching the server capabilities.
|
|
*/
|
|
start(): void;
|
|
/**
|
|
* Stops the service
|
|
*/
|
|
stop(): void;
|
|
/**
|
|
* Returns the cached capabilities, or undefined if none are cached.
|
|
* @returns the current capabilities, if any.
|
|
*/
|
|
getCached(): ResponseType | undefined;
|
|
abstract fetch(): Promise<ResponseType>;
|
|
private poll;
|
|
private clearTimeouts;
|
|
}
|
|
//# sourceMappingURL=capabilityPoller.d.ts.map
|