You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val data = snapshotFlow { buildFromState() }.debounce(1.seconds)
...
data.collectAsState(null)
to remove the view side default null value.
But there's no easy way to debounce in Molecule. I think the closest you can get would be
val debouncedFlow = snapshotFlow { buildFromState() }.debounce(1.seconds)
val state = scope.launchMolecule {
debouncedFlow.collectAsState(buildFromState()).value
}
but this moves from Compose (the actual state) -> Flow (snapshotFlow) -> Molecule -> Compose (collectAsState) -> Compose UI, which is very inefficient compared to reading the state directly inside Molecule. It also requires calling buildFromState() redundantly.
If there was a way to control/throttle the recomposition timing in Molecule, then I could try and make it only recompose every second or when the debounce concluded.
The text was updated successfully, but these errors were encountered:
I think that perhaps we want to consider accepting a frame clock even when using immediate mode. This would allow you to use an at-most-once-a-second frame clock either directly, or with the immediate mode. It would apply the back pressure to the recomposition rather than allowing it to run unbounded simply to discard its results.
I think that perhaps we want to consider accepting a frame clock even when using immediate mode.
I would think this would be equivalent to using the frame clock directly. What advantage does this give us over providing some utility code to create frame clocks from Flow<Unit>, or something similar?
I was thinking that there was some advantage to still using the immediate mode such as immediately running if the period had already expired, but you're right that's just clock implementation details.
I'm trying to migrate
to remove the view side default
null
value.But there's no easy way to debounce in Molecule. I think the closest you can get would be
but this moves from Compose (the actual state) -> Flow (
snapshotFlow
) -> Molecule -> Compose (collectAsState
) -> Compose UI, which is very inefficient compared to reading the state directly inside Molecule. It also requires callingbuildFromState()
redundantly.If there was a way to control/throttle the recomposition timing in Molecule, then I could try and make it only recompose every second or when the debounce concluded.
The text was updated successfully, but these errors were encountered: