sycamore-rs / sycamore

A library for creating reactive web apps in Rust and WebAssembly
https://sycamore-rs.netlify.app
MIT License
2.79k stars 148 forks source link

Typed event data + async event handlers #553

Closed lukechu10 closed 1 year ago

lukechu10 commented 1 year ago

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.

codecov[bot] commented 1 year ago

Codecov Report

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

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

:exclamation: 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 ```diff @@ 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](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs) | Coverage Δ | | |---|---|---| | [packages/sycamore-core/src/event.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtY29yZS9zcmMvZXZlbnQucnM=) | `0.00% <0.00%> (ø)` | | | [packages/sycamore-core/src/generic\_node.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtY29yZS9zcmMvZ2VuZXJpY19ub2RlLnJz) | `75.00% <ø> (ø)` | | | [packages/sycamore-core/src/lib.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtY29yZS9zcmMvbGliLnJz) | `100.00% <ø> (ø)` | | | [packages/sycamore-macro/src/view/ir.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtbWFjcm8vc3JjL3ZpZXcvaXIucnM=) | `100.00% <ø> (ø)` | | | [packages/sycamore-router/src/router.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtcm91dGVyL3NyYy9yb3V0ZXIucnM=) | `27.88% <0.00%> (ø)` | | | [packages/sycamore-web/src/dom\_node.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtd2ViL3NyYy9kb21fbm9kZS5ycw==) | `0.00% <0.00%> (ø)` | | | [packages/sycamore-web/src/hydrate\_node.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtd2ViL3NyYy9oeWRyYXRlX25vZGUucnM=) | `0.00% <0.00%> (ø)` | | | [packages/sycamore-web/src/lib.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUtd2ViL3NyYy9saWIucnM=) | `21.42% <ø> (ø)` | | | [packages/sycamore/src/builder.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUvc3JjL2J1aWxkZXIucnM=) | `24.51% <0.00%> (ø)` | | | [packages/sycamore/src/web/html.rs](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs#diff-cGFja2FnZXMvc3ljYW1vcmUvc3JjL3dlYi9odG1sLnJz) | `69.36% <0.00%> (-0.30%)` | :arrow_down: | | ... and [4 more](https://codecov.io/gh/sycamore-rs/sycamore/pull/553?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sycamore-rs)

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

piaoger commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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 :)