dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Allow degrading Signal<T, SyncStorage> into Signal<T, UnsyncStorage>

Open Enduriel opened this issue 1 year ago • 0 comments

Feature Request

The ability to accept a Signal<T, SyncStorage> where a function or component requires a Signal<T, UnsyncStorage>

This would be very useful because it would prevent SyncSignals from infecting a lot of your application where they are not necessary. In my case I have a logger object I need to be able to write to from a separate thread, but in the vast majority of cases I only need to be able to write to it from the main thread, so while the signal does need to be a SyncSignal, in the majority of cases I don't need to use it as such.

Implement Suggestion

I haven't used Dioxus enough or spent enough time in the codebase to be able to provide a good suggestion here, but I can imagine two approaches, either make SyncStorage/UnsyncStorage traits and have impl<UnsyncStorage> for SyncStorage, or add a impl From<SyncStorage> for UnsyncStorage.

Enduriel avatar Jun 14 '24 09:06 Enduriel