androidx.compose.foundation.lazy

LazyListPrefetchStrategyExperimental

Interface · from org.jetbrains.compose.foundation:foundation:1.12.2

No hand-written docs yet.

Implementations of this interface control which indices of a LazyList should be prefetched (precomposed and premeasured during idle time) as the user interacts with it.

interface LazyListPrefetchStrategy

How to get one

Create it

Used by

Parameters that take a LazyListPrefetchStrategy.

Functions

onScroll

fun LazyListPrefetchScope.onScroll(delta: Float, layoutInfo: LazyListLayoutInfo)

onScroll is invoked when the LazyList scrolls, whether or not the visible items have changed. If the visible items have also changed, then this will be invoked in the same frame after onVisibleItemsUpdated.

onVisibleItemsUpdated

fun LazyListPrefetchScope.onVisibleItemsUpdated(layoutInfo: LazyListLayoutInfo)

onVisibleItemsUpdated is invoked when the LazyList scrolls if the visible items have changed.

onNestedPrefetch

fun NestedPrefetchScope.onNestedPrefetch(firstVisibleItemIndex: Int)

onNestedPrefetch is invoked when a parent LazyLayout has prefetched content which contains this LazyList. It gives this LazyList a chance to request prefetch for some of its own children before coming onto screen.

Library docs

Implementations of this interface control which indices of a LazyList should be prefetched (precomposed and premeasured during idle time) as the user interacts with it.

Implementations should invoke LazyListPrefetchScope.schedulePrefetch to schedule prefetches from the onScroll and onVisibleItemsUpdated callbacks. If any of the returned PrefetchHandles no longer need to be prefetched, use LazyLayoutPrefetchState.PrefetchHandle.cancel to cancel the request.