docs(mobile/4): fix the shared() #[On] listener example - #527
Merged
Merged
Conversation
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) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #446.
The
shared()example on the Async Tasks page is wrong. It takes a single$eventargument and reads$event->result, but#[On]methods get payload keys bound to their parameter names. Theshared()payload hasid,resultandstatuskeys and noeventkey, so a screen that copies the example breaks as soon as the task finishes. We hit this testing the super-native demo.This changes the example to bind
$resultand$statusby name, spells out which keys the success and failure payloads carry, and adds a short aside on why every parameter needs a default.The aside doesn't name the exception on purpose. It was an
ArgumentCountErrorwhen we found this, and it's aBindingResolutionExceptionon mobile-air main now that#[On]calls go throughComponentMethodInvoker.The matching test coverage is in NativePHP/mobile-air#484.
🤖 Generated with Claude Code