vite-plugin-shopify-theme-islands
Version:
Vite plugin for island architecture in Shopify themes
21 lines (20 loc) • 931 B
TypeScript
/**
* A registry of element-scoped cancellation callbacks.
*
* The runtime registers a cancel callback per Island element that has pending
* Gate work (e.g. a `client:visible` IntersectionObserver subscription). When
* the element is removed from the DOM, or its containing Subtree is excluded,
* those callbacks fire so the pending work doesn't leak.
*/
export interface CancellableWatchers {
/**
* Register a cancel callback for an element. Returns a dispose function that
* removes just this callback (other callbacks for the same element stay).
*/
watch(el: Element, cancel: () => void): () => void;
/** Fire and forget every callback whose element is no longer connected. */
cancelDetached(): void;
/** Fire and forget every callback whose element is inside `root`. */
cancelInRoot(root: Element): void;
}
export declare function createCancellableWatchers(): CancellableWatchers;