Skip to content

Typed event data + async event handlers #553

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

Merged
merged 6 commits into from
Jan 5, 2023

Conversation

lukechu10
Copy link
Member

@lukechu10 lukechu10 commented Jan 5, 2023

Closes #241 and #506

Async event handlers somehow do not type check yet.

This is a breaking change because closures now accept different types as arguments depending on the event used. This is also a breaking change because invalid event names are no longer allowed, and the event structs must be used explicitly when using the builder API.

@lukechu10 lukechu10 added C-enhancement Category: new feature or improvement to existing feature BREAKING CHANGE Breaking changes introduced in this PR A-ergonomics Area: API ergonomics labels Jan 5, 2023
@lukechu10 lukechu10 added this to the v0.9 milestone Jan 5, 2023
@codecov
Copy link

codecov bot commented Jan 5, 2023

Codecov Report

Base: 63.28% // Head: 63.09% // Decreases project coverage by -0.19% ⚠️

Coverage data is based on head (6e52e49) compared to base (9c5c12e).
Patch coverage: 29.23% of modified lines in pull request are covered.

❗ Current head 6e52e49 differs from pull request most recent head b59589c. Consider uploading reports for the commit b59589c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
- Coverage   63.28%   63.09%   -0.20%     
==========================================
  Files          54       55       +1     
  Lines        8952     8995      +43     
==========================================
+ Hits         5665     5675      +10     
- Misses       3287     3320      +33     
Impacted Files Coverage Δ
packages/sycamore-core/src/event.rs 0.00% <0.00%> (ø)
packages/sycamore-core/src/generic_node.rs 75.00% <ø> (ø)
packages/sycamore-core/src/lib.rs 100.00% <ø> (ø)
packages/sycamore-macro/src/view/ir.rs 100.00% <ø> (ø)
packages/sycamore-router/src/router.rs 27.88% <0.00%> (ø)
packages/sycamore-web/src/dom_node.rs 0.00% <0.00%> (ø)
packages/sycamore-web/src/hydrate_node.rs 0.00% <0.00%> (ø)
packages/sycamore-web/src/lib.rs 21.42% <ø> (ø)
packages/sycamore/src/builder.rs 24.51% <0.00%> (ø)
packages/sycamore/src/web/html.rs 69.36% <0.00%> (-0.30%) ⬇️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

There was an erroneous GenericNode bound on the wrong type generic
@lukechu10 lukechu10 marked this pull request as ready for review January 5, 2023 05:43
@lukechu10 lukechu10 changed the title Typed event data Typed event data + async event handlers Jan 5, 2023
@lukechu10 lukechu10 enabled auto-merge (squash) January 5, 2023 06:03
@lukechu10 lukechu10 linked an issue Jan 5, 2023 that may be closed by this pull request
@lukechu10 lukechu10 merged commit e402f11 into sycamore-rs:master Jan 5, 2023
@lukechu10 lukechu10 deleted the typed-events branch January 5, 2023 06:16
@piaoger
Copy link

piaoger commented Jan 7, 2023

@lukechu10
I am not sure if it's right place or time for my question :) ev seems so short for naming, maybe evt is better.

@lukechu10
Copy link
Member Author

@lukechu10 I am not sure if it's right place or time for my question :) ev seems so short for naming, maybe evt is better.

We can still change it but I am personally in favor of ev. It is quite common to see "ev" for an abbreviation of "event" in event handlers.

@piaoger
Copy link

piaoger commented Jan 10, 2023

We can still change it but I am personally in favor of ev. It is quite common to see "ev" for an abbreviation of "event" in event handlers.

@lukechu10
Thanks for your effort on Sycamore 👍
I have no problem now and then I can update my indoor app to align with latest changes in main branch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ergonomics Area: API ergonomics BREAKING CHANGE Breaking changes introduced in this PR C-enhancement Category: new feature or improvement to existing feature
Projects
Development

Successfully merging this pull request may close these issues.

Async event handlers Typed Event Handlers
2 participants