From f1e855b9357deb4d16034f8616080542d1de2471 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sat, 19 Sep 2026 16:25:43 +0100 Subject: [PATCH] docs(mobile/4): fix the shared() #[On] listener example The example took a single $event argument and read $event->result. #[On] methods get payload keys bound to their parameter names, and the shared() payload has no event key, so copying the example breaks the screen as soon as the task finishes. Bind result and status by name instead, list what each payload carries, and explain why every parameter needs a default. Co-Authored-By: Claude Opus 5 (1M context) --- .../docs/mobile/4/digging-deeper/async-tasks.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index c187201d1..a968cf82f 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -143,14 +143,22 @@ up with `#[On]`: use Native\Mobile\Attributes\On; #[On('sync-complete')] -public function syncComplete($event): void +public function syncComplete(mixed $result = null, string $status = 'finished'): void { - $this->lastSync = $event->result; + $this->lastSync = $result; } ``` -The event payload carries `id`, a `status` of `finished` or `failed`, and either `result` or the failure -details. +The payload carries `id`, a `status` of `finished` or `failed`, and then either `result` (on success) or +`exceptionClass`, `message` and `trace` (on failure). + + ## Running several at once