Skip to content

Conversation

@steve-the-edwards
Copy link
Contributor

No description provided.

"Collection dispatch should happen on the lifecycle's dispatcher."
withContext(collectionContext) {
require(Looper.myLooper() == Looper.getMainLooper()) {
"Collection dispatch should happen on the main thread!"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/should/must

* @param [collectionContext] additional [CoroutineContext] we want for the coroutine that is
* launched to collect the renderings. This should not override the [CoroutineDispatcher][kotlinx.coroutines.CoroutineDispatcher]
* but may include some other instrumentation elements.
* launched to collect the renderings, can include a different dispatcher - but it should be
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested wording: "can include a different dispatcher - but we verify that it's a main thread dispatcher" And maybe explain why this restriction exists (naively I thought all of this stuff was immutable so it'd be safe to access them from any thread)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is not for the runtime actually, this is where we collect the emitted renderings from the runtime and update the views that show them.

so we need to get main thread here to update those views.

The wording change is good though!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...but we verify that it is a main thread dispatcher since we are updating views here!

unoriginal.show(BScreen(), env)
}

@Test fun usesLifecycleDispatcher() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any test coverage now? If you took out the withContext statement and just ran the block directly would any test fail? (If not, I think we should test that)

steve-the-edwards and others added 2 commits November 13, 2025 11:06
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@steve-the-edwards steve-the-edwards force-pushed the sedwards/update-take-dispatcher-rules branch from 86bc859 to 6e02bc9 Compare November 13, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants