Feature Request
Signals do support serde for T: serde
but I couldn't find any equivalent for Stores
Implement Suggestion
here is Signal's current implementation :
|
#[cfg(feature = "serialize")] |
|
impl<T: serde::Serialize + 'static, Store: Storage<SignalData<T>> + 'static> serde::Serialize |
|
for Signal<T, Store> |
|
{ |
|
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
|
self.read().serialize(serializer) |
|
} |
|
} |
|
|
|
#[cfg(feature = "serialize")] |
|
impl<'de, T: serde::Deserialize<'de> + 'static, Store: Storage<SignalData<T>> + 'static> |
|
serde::Deserialize<'de> for Signal<T, Store> |
|
{ |
|
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { |
|
Ok(Self::new_maybe_sync(T::deserialize(deserializer)?)) |
|
} |
|
} |
I assume it would go the same way for Stores,
as it's pretty much literally a like Signal from the read/new api pov.
I can send a PR with it, if there aren't other subtleties arising from this change, please let me know.
slightly unrelated, but that's what brought me here
might be some kind of XY problem,
I realized serde was missing from Stores when I wanted to use dioxus_sdk's use_storage with a Store<T>.
I know that use_storage gives a Signal<T>, but I needed a Store<T> to access my Type's Lenses...
I'm pretty sure there might be a way to convert the use_storage's Signal into a Store without having nested Signal<Store<T>>, while keeping the Store reactively updating the storage, but I couldn't figure it out...
Thanks forward
Feature Request
Signals do support serde forT: serdebut I couldn't find any equivalent for
StoresImplement Suggestion
here is Signal's current implementation :
dioxus/packages/signals/src/signal.rs
Lines 500 to 516 in e2cc82e
I assume it would go the same way for
Stores,as it's pretty much literally a like
Signalfrom theread/newapi pov.I can send a PR with it, if there aren't other subtleties arising from this change, please let me know.
slightly unrelated, but that's what brought me here
might be some kind of XY problem,
I realized serde was missing from
Stores when I wanted to usedioxus_sdk'suse_storagewith aStore<T>.I know that
use_storagegives aSignal<T>, but I needed aStore<T>to access my Type's Lenses...I'm pretty sure there might be a way to convert the
use_storage'sSignalinto aStorewithout having nestedSignal<Store<T>>, while keeping the Store reactively updating the storage, but I couldn't figure it out...Thanks forward