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

Update todo-app.md #785

Closed
wants to merge 1 commit into from
Closed

Update todo-app.md #785

wants to merge 1 commit into from

Conversation

ZAZPRO
Copy link

@ZAZPRO ZAZPRO commented Feb 1, 2025

Just followed introduction tutorial and faced an outdated part.

Web_sys window api is a feature and it is required for the local_storage access. And it returns an result so unwrap/expect is required.

Docs

Also looks like KeyboardEvents are now part of sycamore, not web_sys.

Just followed introduction tutorial and faced an outdated part.
Web_sys window api is a feature and it is required for the local_storage access. And it returns an result so unwrap/expect is required.
https://docs.rs/web-sys/0.3.77/web_sys/struct.Window.html#method.local_storage

Also looks like KeyboardEvents are now part of sycamore, not web_sys
Copy link

codecov bot commented Feb 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.42%. Comparing base (8f2f81b) to head (b73f7b8).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #785   +/-   ##
=======================================
  Coverage   71.42%   71.42%           
=======================================
  Files          45       45           
  Lines        6659     6659           
=======================================
  Hits         4756     4756           
  Misses       1903     1903           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lukechu10
Copy link
Member

Sycamore has it’s own reexport of window which handles the unwrap already: https://docs.rs/sycamore/latest/sycamore/prelude/fn.window.html

Maybe we should make it more explicit that we import the prelude first?

@@ -355,8 +355,8 @@ Here is the complete code listing for the todo app.

```rust
use serde::{Deserialize, Serialize};
use sycamore::prelude::*;
use web_sys::KeyboardEvent;
use sycamore::{prelude::*, web::events::KeyboardEvent};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very small thing but could you split this up into two use statements? This is how it is formatted in other places as well just for consistency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have just copied and build the tutorial code before submitting this issue. Rust-analyzer was screaming at me that window function doesn't exist, that is why I searched for web_sys local storage requirements. I will close this pull request. Thanks for your time :)

@ZAZPRO ZAZPRO closed this Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants