The presenter API's .get(index)
call is what triggers item access to the rest of Paging. Generally you need to call this function in order to bind items to a RecyclerView.Adapter
, but leanback and compose work similarly.
On item access, an internal object called ViewportHint
is sent which contains presenter-state including how many items post-transformation you can see and your current position in the list, which can be handled asyncly from rest of UI.
Paging then essentially triggers loads based on PagingConfig.prefetchDistance
, but has a lot of logic handling race conditions, access conflation, cancellations, tracking load state, error handling, etc. which all can affect what ends up getting loaded in the end.
If you want to access but avoid triggering loads, there are .peek()
and .snapshot()
APIs that let you inspect presenter state without fetching.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…