Skip to content

docs(mobile/4): document async tasks#446

Draft
simonhamp wants to merge 1 commit into
mainfrom
async-tasks
Draft

docs(mobile/4): document async tasks#446
simonhamp wants to merge 1 commit into
mainfrom
async-tasks

Conversation

@simonhamp

Copy link
Copy Markdown
Member

What

Adds a new Async Tasks page to the NativePHP Mobile v4 docs, under Digging Deeper (order: 240, between Push Notifications and Queues).

Why

Async tasks were undocumented. Without a reference page, the two things most likely to bite people are invisible:

  • the work closure must be static (a non-static closure throws at dispatch time), and
  • finished() / failed() callbacks are scoped to the screen that dispatched them, so they're dropped if the user navigates away.

Contents

  • Overview, with the freeze-the-screen problem async tasks solve
  • Why the work closure must be static, and how to pass data in via use
  • finished() and failed(), including the AsyncTaskException stand-in and originalClass()
  • Screen-scoped callbacks vs. shared() named events consumed with #[On]
  • Running several tasks concurrently against the background context pool
  • Task classes extending AsyncTask with a handle() method
  • Testing with AsyncTask::fake() and its available assertions
  • A How It Works section covering the background PHP context and the native event channel
  • Things to Note summary

Throughout, the page draws a clear line between async tasks and queued jobs — async tasks are not durable, not retried, and don't survive the app being killed — and cross-links to the existing Queues page.

Docs only; no application code changed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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