From ffd4f0a6fe97b83fea126d8257e9541d1cddc6f7 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Fri, 26 Jul 2024 10:36:39 +0100 Subject: [PATCH] fixed compile error with use_storage --- CHANGELOG.md | 3 ++- src/storage/use_storage.rs | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c06a3..d9734c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,8 +44,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `JsonCodec` has been renamed to `JsonSerdeCodec`. - The feature to enable this codec is now called `json_serde` instead of just `serde`. - `ProstCodec` now encodes as binary data. If you want to keep using it with string data you can wrap it like - this: `Base64`. You have to enable both features `prost` and `base64` for this. + this: `Base64`. - All of these structs, traits and features now live in their own crate called `codee` + - A bunch of new codecs are available. Have a look at the docs for crate `codee`. - `use_websocket`: - `UseWebsocketOptions` has been renamed to `UseWebSocketOptions` (uppercase S) to be consistent with the return type. diff --git a/src/storage/use_storage.rs b/src/storage/use_storage.rs index 1c31fea..73eaa35 100644 --- a/src/storage/use_storage.rs +++ b/src/storage/use_storage.rs @@ -276,13 +276,17 @@ where let notify = create_trigger(); // Refetch from storage. Keeps track of how many times we've been notified. Does not increment for calls to set_data - let notify_id = create_memo::(move |prev| { - notify.track(); - match prev { - None => 1, // Avoid async fetch of initial value - Some(prev) => { - fetch_from_storage(); - prev + 1 + let notify_id = create_memo::({ + let fetch_from_storage = fetch_from_storage.clone(); + + move |prev| { + notify.track(); + match prev { + None => 1, // Avoid async fetch of initial value + Some(prev) => { + fetch_from_storage(); + prev + 1 + } } } });