Skip to content

Recommend async tasks over #[Lazy] for slow screens - #548

Merged
simonhamp merged 1 commit into
mainfrom
docs/lazy-prefer-async-tasks
Oct 2, 2026
Merged

simonhamp merged 1 commit into
mainfrom
docs/lazy-prefer-async-tasks

Conversation

@simonhamp

Copy link
Copy Markdown
Member

Adds an aside to the `#[Lazy]` section of the mobile v4 lifecycle hooks page recommending async tasks instead.

`#[Lazy]` shows a placeholder, but `mount()` still runs on the UI thread. Until it returns the user can't interact with the screen or go back. Dispatching the slow work from `mount()` with `$this->async()` renders the real screen straight away, keeps it interactive, and lets the dev choose where the loading state goes. The aside includes a short example of that.

I also removed "in the background" from the intro sentence, because `mount()` doesn't run in the background.

Dispatching from `mount()` is covered by `AsyncTaskCompletionTest` in mobile-air.

🤖 Generated with Claude Code

#[Lazy] runs mount() on the UI thread, so the screen can't be used or left
until it returns. Async tasks render the real screen straight away and keep
it interactive, so recommend them for slow screens.

Also drop "in the background" from the #[Lazy] intro, since mount() doesn't
run in the background.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@simonhamp
simonhamp merged commit 494d738 into main Oct 2, 2026
3 checks passed
@simonhamp
simonhamp deleted the docs/lazy-prefer-async-tasks branch October 2, 2026 11:11
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