Skip to content

Deliver native #[On] events and #[Poll] timers to nested components - #505

Closed
ngunyimacharia wants to merge 1 commit into
NativePHP:mainfrom
ngunyimacharia:fix/edge-nested-poll-and-on-v2
Closed

ngunyimacharia wants to merge 1 commit into
NativePHP:mainfrom
ngunyimacharia:fix/edge-nested-poll-and-on-v2

Conversation

@ngunyimacharia

@ngunyimacharia ngunyimacharia commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Native events and #[Poll] timers only reach the root screen. A nested component's #[On] listeners never fire, and its polls never run.

Component events already walk the whole tree (deliverComponentEvent()), and so does Livewire: every listening component on the page gets a dispatched event, and a child's wire:poll polls on its own. Native events and polls were the odd ones out.

Fix

The host now walks its component tree (componentTree()) when it:

  • delivers a native event to #[On] listeners
  • works out the next poll deadline
  • runs due polls

Global dispatch still fires once per event.

Behavior change: a nested component that already declares #[Poll] will now actually poll, and each tick re-renders the host.

Supersedes #413.

Performance

The cost is about 0.5 µs per child per runloop wake-up, and about 0.8 µs per child per native event. Attributes are reflected once per instance and cached. I measured it over 20k calls:

per call before 1 child 20 children 200 children
nextEventTimeout() ~1.3 µs 2.2 µs 11.9 µs 104 µs
runDuePolls() ~2 µs 2.9 µs 11.0 µs 88 µs
dispatchNativeEvent() ~17 µs 19.1 µs 34.0 µs 175 µs

Tests

tests/Feature/Edge/NestedPollAndOnTest.php covers child polls, child poll deadlines and child #[On] delivery.

@ngunyimacharia

Copy link
Copy Markdown
Contributor Author

Trying a different approach.

@ngunyimacharia
ngunyimacharia deleted the fix/edge-nested-poll-and-on-v2 branch October 2, 2026 12:43
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