Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework Event System #1402

Merged
merged 65 commits into from
Jan 5, 2024
Merged

Rework Event System #1402

merged 65 commits into from
Jan 5, 2024

Conversation

ealmloff
Copy link
Member

@ealmloff ealmloff commented Aug 25, 2023

There are three main goals here:

This is built on top of the better pointer events introduced in #1394

closes #1163
closes #93

@ealmloff ealmloff added breaking This is a breaking change html Related to the html crate labels Aug 25, 2023
@esimkowitz
Copy link
Contributor

This is freaking awesome! Curious for my own learning: does this place an additional burden on code that clones/copies an event to allocate additional space on the heap? I'm assuming the Box can't be reused by copied instances right?

@esimkowitz
Copy link
Contributor

esimkowitz commented Aug 26, 2023

Or building on that, does this place an additional burden on the transmission system to allocate additional space for every event?

@ealmloff
Copy link
Member Author

ealmloff commented Aug 26, 2023

This is freaking awesome! Curious for my own learning: does this place an additional burden on code that clones/copies an event to allocate additional space on the heap? I'm assuming the Box can't be reused by copied instances right?

The virtual dom will receive one non-specific web event. That event is wrapped in an Rc so that it will not be cloned. The virtual dom will bubble that event to event handlers. Each event handler will downcast it to the specific event that is needed. Downcasting work will be duplicated if the event bubbles, but it should be fairly cheap. Downcasting in the event handler is what lets us do bundle splitting better.

Once the event is downcast, calling any methods on it will get the needed data from it. For example if you call modifiers, it will build a modifiers struct every time instead of caching it. This is slightly inefficient, but because the old implementation used a depreciated old store of data we were doing this anyway.

Or building on that, does this place an additional burden on the transmission system to allocate additional space for every event?

On the web renderer, we should allocate less in general because we don't get all of the data eagerly when we receive an event. For native/liveview events, we just use the old serialized form of data so it should be the same.

@sdwoodbury
Copy link
Contributor

this branch needs the tray feature. it was added to the fix-event-bubbling branch but not this one.

@ealmloff
Copy link
Member Author

ealmloff commented Oct 3, 2023

this branch needs the tray feature. it was added to the fix-event-bubbling branch but not this one.

The branch was a few commits behind the main branch. I just pulled in the latest changes. (this happens automatically when the PR is merged)

@ealmloff ealmloff mentioned this pull request Oct 5, 2023
@esimkowitz
Copy link
Contributor

@ealmloff are you holding this for the 0.5 release? May be good to add a milestone tag for it

@ealmloff
Copy link
Member Author

@ealmloff are you holding this for the 0.5 release? May be good to add a milestone tag for it

Yes, everything breaking is for 0.5

@ealmloff ealmloff added this to the 0.5 Release milestone Oct 10, 2023
@jkelleyrtp jkelleyrtp merged commit 4debd9c into DioxusLabs:master Jan 5, 2024
5 of 10 checks passed
@ealmloff ealmloff deleted the events-2 branch January 5, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This is a breaking change bug Something isn't working html Related to the html crate
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Improve Event System Code Snipping Access to native event type in web
4 participants