UNPKG

vite-plugin-shopify-theme-islands

Version:
33 lines (32 loc) 994 B
import type { IslandLoadDetail, IslandErrorDetail } from "./contract.js"; /** * Listen for successful island module loads. * * Returns a cleanup function that removes the listener. * * @example * ```ts * import { onIslandLoad } from "vite-plugin-shopify-theme-islands/events"; * * const off = onIslandLoad(({ tag }) => { * analytics.track("island_loaded", { tag }); * }); * ``` */ export declare function onIslandLoad(handler: (detail: IslandLoadDetail) => void): () => void; /** * Listen for island load or custom directive failures. * * Fires on each retry attempt, not just the final failure. * Returns a cleanup function that removes the listener. * * @example * ```ts * import { onIslandError } from "vite-plugin-shopify-theme-islands/events"; * * const off = onIslandError(({ tag, error }) => { * errorReporter.capture(error, { context: tag }); * }); * ``` */ export declare function onIslandError(handler: (detail: IslandErrorDetail) => void): () => void;