You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
28 lines
1.0 KiB
import type TypedEmitter from "typed-emitter";
|
|
import type { ConnectedResult } from "./results/ConnectedResult";
|
|
import type { ResourceResult } from "./results/ResourceResult";
|
|
import type { SubscriptionCallbacks } from "./notifications/NotificationSubscription";
|
|
|
|
export type ResourceEventEmitter = TypedEmitter<{
|
|
update: () => void;
|
|
notification: () => void;
|
|
}>;
|
|
|
|
export interface Resource<UriType extends string = string>
|
|
extends ResourceEventEmitter {
|
|
readonly uri: UriType;
|
|
readonly type: string;
|
|
status: ConnectedResult;
|
|
isLoading(): boolean;
|
|
isFetched(): boolean;
|
|
isUnfetched(): boolean;
|
|
isDoingInitialFetch(): boolean;
|
|
isPresent(): boolean;
|
|
isAbsent(): boolean;
|
|
isSubscribedToNotifications(): boolean;
|
|
read(): Promise<ResourceResult<this>>;
|
|
readIfAbsent(): Promise<ResourceResult<this>>;
|
|
subscribeToNotifications(callbacks?: SubscriptionCallbacks): Promise<string>;
|
|
unsubscribeFromNotifications(subscriptionId: string): Promise<void>;
|
|
unsubscribeFromAllNotifications(): Promise<void>;
|
|
}
|
|
|