Repository navigation
Give MoleculeViewModel a frame clock on the JVM - #3373
Closed
StylianosGakis wants to merge 1 commit into
Closed
StylianosGakis wants to merge 1 commit into
StylianosGakis wants to merge 1 commit into
Conversation
RecompositionMode.ContextClock needs a MonotonicFrameClock in the coroutine context. Dispatchers.Main on the JVM carries none, so a MoleculeViewModel's presenter failed inside the sharing coroutine and uiState never moved past its initial value. The JVM actual now adds a clock that hands out a frame every 16 ms through delay, which runs on the Swing timer in a desktop app and on virtual time under a test dispatcher.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI description
Makes
MoleculeViewModelwork on the JVM target. Its dispatcher there had no frame clock, so the molecule threwA MonotonicFrameClock is not available in this CoroutineContextinside thestateIncoroutine, where it was swallowed: presenters never ran and nothing was logged. That blocks running the app on desktop, which is where this is heading.The JVM dispatcher now carries a small clock that completes each frame request 16 ms after it is made. It is
delaybased because a ViewModel cannot reach a desktop window's own frame clock, and so it also works under a test dispatcher. It costs nothing while idle: the recomposer only asks for a frame after an invalidation.Only the JVM source set changes. No existing test constructed a
MoleculeViewModel(they drive presenters directly), so the new test is the first to cover this path.Not yet exercised in a real desktop window.