From 6ff0ffa098d768d4cda22f748591ba93df8b58b8 Mon Sep 17 00:00:00 2001 From: Calvin Liang Date: Mon, 27 May 2024 09:20:30 -0700 Subject: [PATCH] update README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index d4864d2..4db28d8 100644 --- a/README.md +++ b/README.md @@ -796,6 +796,17 @@ If the items in the list do not contain any button besides the drag handle, I re The `onMove` function expects the list to be updated before it returns. If the list is updated after `onMove` returns, the dragging item will flicker. To fix this, update the list before returning from `onMove`. +```kotlin +val reorderableLazyXXXXState = rememberReorderableLazyXXXXState(listState) { from, to -> + // do NOT wrap the updateList call in `launch` + updateList(from, to) +} + +suspend fun updateList(from: Int, to: Int) { + // long update operation +} +``` + If you can't keep the list update inside `onMove`, you can use a channel to communicate between `onMove` and the list update composition. Here's an example: ```kotlin