Skip to content

Commit

Permalink
Merge pull request #83 from qdsfdhvh/feature/support_new_molecule
Browse files Browse the repository at this point in the history
support  molecule 1.1.0
  • Loading branch information
Tlaster authored Aug 4, 2023
2 parents 80defb7 + 219605b commit 1df2df7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin = "1.9.0"
kotlinxCoroutinesCore = "1.7.3"
lifecycleRuntimeKtx = "2.6.1"
material = "1.5.0-beta03"
moleculeRuntime = "0.9.0"
moleculeRuntime = "1.1.0"
savedstateKtx = "1.2.1"
spotless = "6.7.0"
jetbrainsComposePlugin = "1.5.0-beta01"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import app.cash.molecule.RecompositionClock
import app.cash.molecule.RecompositionMode
import app.cash.molecule.launchMolecule
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
Expand All @@ -27,10 +27,10 @@ private class PresenterHolder<T>(
body: @Composable () -> T,
) : AutoCloseable {
private val dispatcher = providePlatformDispatcher()
private val clock = if (dispatcher[MonotonicFrameClock] == null || useImmediateClock) {
RecompositionClock.Immediate
private val clock = if (useImmediateClock || dispatcher[MonotonicFrameClock] == null) {
RecompositionMode.Immediate
} else {
RecompositionClock.ContextClock
RecompositionMode.ContextClock
}
private val scope = CoroutineScope(dispatcher)
val state = scope.launchMolecule(clock, body)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package moe.tlaster.precompose.molecule

import app.cash.molecule.DisplayLinkClock
import kotlinx.coroutines.Dispatchers
import kotlin.coroutines.CoroutineContext

internal actual fun providePlatformDispatcher(): CoroutineContext = Dispatchers.Main
internal actual fun providePlatformDispatcher(): CoroutineContext = Dispatchers.Main + DisplayLinkClock

0 comments on commit 1df2df7

Please sign in to comment.