DioxusLabs / DioxusLabs/sdk

Synced local storage on web goes out of sync when second window writes to the signal

Open
#77 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
302
Forks
58
PR merge metrics
No merged PRs in 30d

Description

Hi there, I think I've found a bug. with this minimal example, built for the web platform:
```rust
use dioxus::prelude::*;
use dioxus_sdk::storage::*;

fn main() {
dioxus::launch(App);
}

#[component]
fn App() -> Element {
let mut state = use_synced_storage::("state".to_string(), || false);

rsx! {
div {
button {
onclick: move |_| {
state.set(!state());
},
"Toggle"
}
if state() {
div {
"State is true"
}
} else {
div {
"State is false"
}
}
}
}
}
```
The issue:
1. load this page in 2 browser windows
2. click the button in one of them repeatedly, see the state change in both reliably and in sync
3. click the button in the other window a few times, see the state quickly go out of sync
4. clicking the button in the first window doesn't sync them up again

I expected both windows to be able to read and write from the local storage entry and see them update in sync. Is this a bug? Should these remain in sync?

Version `0.6.0`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.