Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions resources/views/docs/mobile/4/digging-deeper/async-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<aside>

`#[On]` binds payload keys to your method's **parameter names**, so a parameter called `$result` receives the
payload's `result` key. Give every parameter a default. Success and failure payloads carry different keys, and a
required parameter that isn't in the payload can't be resolved, so the call fails.

</aside>

## Running several at once

Expand Down
Loading