Skip to content

Conversation

@karlseguin
Copy link
Collaborator

The approach borrows heavily from Zig's new LinkedList API.

The main benefit is that it unifies how event callbacks are done. When the Page.windowClick event was added, the Event structure was changed to a union, supporting a distinct Zig and JS event.

This new approach more or less treats everything like a Zig event. A JS event is just a Zig struct that has a Env.Callback which it can invoke in its handle method.

The intrusive nature of the EventNode means that what used to be 1 or 2 allocations is now 0 or 1.

It also has the benefit of making netsurf completely unaware of Env.Callbacks.

The approach borrows heavily from Zig's new LinkedList API.

The main benefit is that it unifies how event callbacks are done. When the
Page.windowClick event was added, the Event structure was changed to a union,
supporting a distinct Zig and JS event.

This new approach more or less treats everything like a Zig event. A JS event
is just a Zig struct that has a Env.Callback which it can invoke in its handle
method.

The intrusive nature of the EventNode means that what used to be 1 or 2
allocations is now 0 or 1.

It also has the benefit of making netsurf completely unaware of Env.Callbacks.
@karlseguin karlseguin merged commit 47c14db into main May 1, 2025
12 checks passed
@karlseguin karlseguin deleted the unified_intrusive_events branch May 1, 2025 01:50
@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants