### Installing svelte-infinite
Source: https://github.com/ndom91/svelte-infinite/blob/main/README.md
This snippet shows how to install the s svelte-infinite package using popular Node.js package managers: npm, pnpm, and yarn. Choose the command corresponding to your preferred package manager.
```bash
npm install svelte-infinite
pnpm install svelte-infinite
yarn add svelte-infinite
```
--------------------------------
### Basic Usage of InfiniteLoader in Svelte
Source: https://github.com/ndom91/svelte-infinite/blob/main/README.md
This Svelte snippet demonstrates the basic usage of the InfiniteLoader component. It imports InfiniteLoader and LoaderState, initializes a LoaderState and an array for items, defines an asynchronous function to load more data, and renders the InfiniteLoader component wrapping an #each block to display items.
```svelte
{#each allItems as user (user.id)}
{user.name}
{/each}
```
--------------------------------
### Implementing Paginated Data Loading with Svelte Infinite
Source: https://github.com/ndom91/svelte-infinite/blob/main/README.md
This Svelte component demonstrates integrating svelte-infinite to load paginated data. It defines an async function `loadMore` that fetches data from an API endpoint, updates the `allItems` state, and manages the loader state using `LoaderState`. It also shows how to use the `InfiniteLoader` component and define custom UI for loading and error states using `#snippet`.
```Svelte
{#each allItems as user (user.id)}
{/each}
{#snippet loading()}
Loading...
{/snippet}
{#snippet error(load)}
Error fetching data
{/snippet}
```
--------------------------------
### InfiniteLoader Component Props
Source: https://github.com/ndom91/svelte-infinite/blob/main/README.md
Configuration options for the InfiniteLoader component, including the state controller, the data loading function, IntersectionObserver options, and loop detection parameters.
```TypeScript
loaderState: LoaderState
```
```TypeScript
triggerLoad: () => Promise
```
```TypeScript
intersectionOptions: IntersectionObserverInit = { rootMargin: "0px 0px 200px 0px" }
```
```TypeScript
loopTimeout: number = 3000
```
```TypeScript
loopDetectionTimeout: number = 2000
```
```TypeScript
loopMaxCalls: number = 5
```
--------------------------------
### InfiniteLoader Component Snippets
Source: https://github.com/ndom91/svelte-infinite/blob/main/README.md
Customizable content slots (snippets in Svelte 5) for the InfiniteLoader component, allowing users to define what is displayed in different states like loading, no data, error, etc.
```Svelte
loading
```
```Svelte
noResults
```
```Svelte
noData
```
```Svelte
coolingOff
```
```Svelte
error
```
--------------------------------
### loaderState Controller Methods
Source: https://github.com/ndom91/svelte-infinite/blob/main/README.md
The loaderState controller provides methods to manage the internal state of the InfiniteLoader component, signaling successful loads, errors, completion, or requiring a reset.
```JavaScript
loaderState.loaded()
```
```JavaScript
loaderState.error()
```
```JavaScript
loaderState.complete()
```
```JavaScript
loaderState.reset()
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.