Skip to content

Add API for awaiting asynchronous Compose resource loads - #5720

Open
Konstantin (terrakok) wants to merge 1 commit into
masterfrom
CMP-8776
Open

Konstantin (terrakok) wants to merge 1 commit into
masterfrom
CMP-8776

Conversation

@terrakok

Copy link
Copy Markdown
Member

Add the experimental awaitPendingResourceStateLoads() API, which allows tests to wait until all currently pending asynchronous resource loads have completed and their results have been written to Compose states.

On blocking platforms the function is a no-op because resource states are calculated synchronously.

Web resource APIs such as stringResource, painterResource, and Font return a default value during the initial composition and update their Compose state after the resource has been loaded asynchronously.

waitForIdle() only waits for Compose work. It does not guarantee that resource loading running outside of Compose has completed. As a result, tests could observe placeholders or stale values even after the UI was considered idle.

The required test sequence is:

waitForIdle()                      // perform composition and start resource loads
awaitPendingResourceStateLoads()   // wait until loaded values are written to State
waitForIdle()                      // process recomposition, layout, and draw

Fixes https://youtrack.jetbrains.com/issue/CMP-8776

Release Notes

Features - Resources

  • New API for awaiting asynchronous Compose resource loads: awaitPendingResourceStateLoads()

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.

1 participant