UNPKG

svelte-infinite

Version:

Infinite scroll for Svelte 5 with Runes

29 lines (28 loc) 669 B
export const STATUS = { READY: "READY", LOADING: "LOADING", COMPLETE: "COMPLETE", ERROR: "ERROR" }; export class LoaderState { isFirstLoad = $state(true); status = $state(STATUS.READY); mounted = $state(false); loaded = () => { if (this.isFirstLoad) this.isFirstLoad = false; this.status = STATUS.READY; }; complete = () => { if (this.isFirstLoad) this.isFirstLoad = false; this.status = STATUS.COMPLETE; }; reset = () => { this.isFirstLoad = true; this.status = STATUS.READY; }; error = () => { this.status = STATUS.ERROR; }; }