Skip to content

Commit

Permalink
fix: replace all atomic snapshot operation (#519)
Browse files Browse the repository at this point in the history
Co-authored-by: Thiago dos Santos <thiagodossantos@BRSAOMN044385.local>
  • Loading branch information
2 people authored and Thiago dos Santos committed Dec 19, 2024
1 parent c7d10cc commit 09946e4
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.listSaver
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.runtime.toMutableStateList

Expand Down Expand Up @@ -111,15 +112,19 @@ public class SnapshotStateStack<Item>(
}

public override infix fun replaceAll(item: Item) {
stateStack.clear()
stateStack += item
lastEvent = StackEvent.Replace
Snapshot.withMutableSnapshot {
stateStack.clear()
stateStack += item
lastEvent = StackEvent.Replace
}
}

public override infix fun replaceAll(items: List<Item>) {
stateStack.clear()
stateStack += items
lastEvent = StackEvent.Replace
Snapshot.withMutableSnapshot {
stateStack.clear()
stateStack += items
lastEvent = StackEvent.Replace
}
}

public override fun pop(): Boolean =
Expand Down

0 comments on commit 09946e4

Please sign in to comment.