Skip to content

2.4.0

Latest

Choose a tag to compare

@xelon-ua xelon-ua released this 20 Oct 21:43

Added

  • itemKey on Pager, StreamingPager and PagingMediatorConfig, and PagingMap.keyAt(index), for keying a
    LazyColumn by item id (#52). A key that briefly appears twice while pages shift is hidden: the copy from older data
    is shown as not yet loaded until the data settles, instead of crashing the list with a duplicate key. A key that
    really appears twice in the source is shown as two rows with unique keys. Without itemKey nothing changes.

Changed

  • Breaking: PagingData gains prefetchState between loadState and retry (#11). loadState now reports only
    the accessed position: Loading while the item there is missing and being fetched, Error when that fetch fails,
    Success as soon as it lands - so LoadState.Loading -> showLoader() no longer shows a spinner for the whole
    preload window or while scrolling over cached data. The rest of the window is reported in prefetchState; its
    failures no longer turn the list into an error. Error.key is always the current accessed position. The old global
    meaning is roughly loadState is Loading || prefetchState is Loading; code constructing PagingData directly must
    pass prefetchState.
  • Breaking: PagingMap is no longer a data class, so item keys cannot be set from outside and stay unique in
    every map a consumer sees (#54). Its public constructor (size, values, onGet) creates a map with fallback keys only;
    copy(size, values, onGet) keeps a position's key only while that position holds an equal value. equals,
    hashCode and toString stay; the componentN functions (destructuring) are gone.
  • The StreamingPager readPortion contract is documented as a merge (#14): an emission may carry only the rows that
    changed, and the positions it leaves out keep their cached values. This is how the pager already behaved; the README
    no longer asks sources to resend the whole portion on every change.
  • paging-samples key their lists by user id through itemKey and keyAt instead of by index, so rows keep their
    state and animate when items are inserted or removed above them (#15). The streaming sample gains an "Insert at top"
    button that adds a user with a new id.
  • Binary compatibility: libraries compiled against 2.3.x that call the Pager, StreamingPager or
    PagingMediatorConfig constructors, or PagingMap.copy / PagingMediatorConfig.copy, must be recompiled against
    2.4.0.

Fixed

  • Item keys, follow-ups to #52 (#54):
    • Pager no longer reloads a page every time a still viewport reads a hidden position that a refetch has already
      failed to fill. refresh() and a failed pass reset that state.
    • Pager resolves conflicts left by a superseded pass even when the next pass has nothing to fetch.
    • StreamingPager no longer confirms a duplicate when the hidden position's window closed and reopened within the
      grace period: the reopened window must emit first.
    • A portion that both adds a position for a key and rewrites a hidden position of that key no longer gives a result
      that depends on the order of the map.
  • StreamingPager keeps the readTotal() outcome apart from the per-range states (#59). A retry no longer marks
    every known range Loading again, so streams that had already emitted and stay quiet no longer leave
    prefetchState stuck at Loading, and a finite readTotal() that completed no longer turns any retry into one.
    A readTotal() failure that arrives before the first page settles is no longer overwritten by that page, and it is
    reported in loadState only. A list whose total is known to be 0 reports Success instead of Loading.