pull/17124/head
Elliott Johnson 1 month ago
parent 8449ea76d8
commit ef11dae8ce

@ -490,7 +490,7 @@ declare module 'svelte' {
export function getAllContexts<T extends Map<any, any> = Map<any, any>>(): T;
export function hydratable<T>(key: string, fn: () => T, { transport }?: {
transport?: Transport;
transport?: Transport<T>;
} | undefined): Promise<T>;
/**
* Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
@ -565,9 +565,9 @@ declare module 'svelte' {
[K in keyof T]: () => T[K];
};
type Transport = {
stringify: (value: unknown) => string;
parse: (value: string) => unknown;
type Transport<T> = {
stringify: (value: T) => string;
parse: (value: string) => T;
};
export {};
@ -2411,42 +2411,37 @@ declare module 'svelte/reactivity' {
* @since 5.7.0
*/
export function createSubscriber(start: (update: () => void) => (() => void) | void): () => void;
export class Resource<T> implements Partial<Promise<T>> {
constructor(fn: () => Promise<T>);
get then(): <TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
get catch(): (reject: any) => Promise<T>;
get finally(): (fn: any) => Promise<any>;
get current(): T | undefined;
get error(): undefined;
/**
* Returns true if the resource is loading or reloading.
*/
get loading(): boolean;
/**
* Returns true once the resource has been loaded for the first time.
*/
get ready(): boolean;
refresh: () => Promise<void>;
set: (value: T) => void;
#private;
}
export function defineResource<TReturn, TArgs extends unknown[] = [], TResource extends typeof Resource = typeof Resource>(name: string, fn: (...args: TArgs) => TReturn, options?: {
Resource?: TResource;
transport?: Transport;
} | undefined): (...args: TArgs) => Resource<TReturn>;
export function resource<T>(fn: () => Promise<T>): Resource<T>;
export function cache<TReturn, TArg extends unknown>(name: string, fn: (arg: TArg, key: string) => TReturn, { hash }?: {
hash?: (arg: TArg) => string;
} | undefined): (arg: TArg) => TReturn;
export function getCache(): ReadonlyMap<string, any>;
class ReactiveValue<T> {
constructor(fn: () => T, onsubscribe: (update: () => void) => void);
get current(): T;
#private;
}
type Transport = {
stringify: (value: unknown) => string;
parse: (value: string) => unknown;
};
type Resource<T> = {
then: Promise<T>['then'];
catch: Promise<T>['catch'];
finally: Promise<T>['finally'];
refresh: () => Promise<void>;
set: (value: T) => void;
loading: boolean;
} & (
| {
ready: false;
value: undefined;
error: undefined;
}
| {
ready: true;
value: T;
error: any;
}
);
export {};
}

Loading…
Cancel
Save