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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/next/introduction/todo-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ so that we can easily serialize `Signal`s.
```bash
cargo add serde -F derive
cargo add serde_json
cargo add web-sys -F Storage
cargo add web-sys -F "Storage,Window"
cargo add sycamore -F serde
```

Then replace the `create_signal` function call with:

```rust
// Initialize application state from localStorage.
let local_storage = window()
let local_storage = window().expect("no window available")
.local_storage()
.unwrap()
.expect("user has not enabled localStorage");
Expand Down Expand Up @@ -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 :)

use web_sys::window;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
struct Todo {
Expand Down
Loading