Repository navigation
Deliver native #[On] events and #[Poll] timers to nested components - #505
Closed
ngunyimacharia wants to merge 1 commit into
Closed
ngunyimacharia wants to merge 1 commit into
ngunyimacharia wants to merge 1 commit into
Conversation
Contributor
Author
|
Trying a different approach. |
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.
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'swire:pollpolls on its own. Native events and polls were the odd ones out.Fix
The host now walks its component tree (
componentTree()) when it:#[On]listenersGlobal 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:
nextEventTimeout()runDuePolls()dispatchNativeEvent()Tests
tests/Feature/Edge/NestedPollAndOnTest.phpcovers child polls, child poll deadlines and child#[On]delivery.