Expand description
Local and persistent storage.
Handle local storage ergonomically.
§Usage
use dioxus_sdk_storage::use_persistent;
use dioxus::prelude::*;
#[component]
fn App() -> Element {
let mut num = use_persistent("count", || 0);
rsx! {
div {
button {
onclick: move |_| {
*num.write() += 1;
},
"Increment"
}
div {
"{*num.read()}"
}
}
}
}Macros§
- set_dir
- Set the directory where the storage files are located on non-wasm targets.
Structs§
- Local
Storage - Session
Storage - Storage
Channel Payload - A payload for a storage channel that contains the latest value from storage.
- Storage
Entry - A storage entry that can be used to store data across application reloads. It optionally provides a channel to subscribe to updates to the underlying storage.
- Storage
Subscription - A struct to hold information about processing a storage event.
- Synced
Storage Entry - A wrapper around StorageEntry that provides a channel to subscribe to updates to the underlying storage.
Traits§
- Storage
Backing - A trait for a storage backing
- Storage
Entry Trait - A trait for common functionality between StorageEntry and SyncedStorageEntry
- Storage
Subscriber - A trait for a subscriber to events from a storage backing
Functions§
- get_
from_ storage - Returns a value from storage or the init value if it doesn’t exist.
- new_
persistent - Creates a persistent storage signal that can be used to store data across application reloads.
- new_
singleton_ persistent - Create a persistent storage signal that can be used to store data across application reloads. The state will be the same for every call to this hook from the same line of code.
- new_
storage - Creates a Signal that can be used to store data that will persist across application reloads.
- new_
storage_ entry - Returns a StorageEntry with the latest value from storage or the init value if it doesn’t exist.
- new_
synced_ storage - Create a signal that can be used to store data that will persist across application reloads and be synced across all app sessions for a given installation or browser.
- new_
synced_ storage_ entry - Returns a synced StorageEntry with the latest value from storage or the init value if it doesn’t exist.
- use_
persistent - A persistent storage hook that can be used to store data across application reloads.
- use_
singleton_ persistent - A persistent storage hook that can be used to store data across application reloads. The state will be the same for every call to this hook from the same line of code.
- use_
storage - A storage hook that can be used to store data that will persist across application reloads. This hook is generic over the storage location which can be useful for other hooks.
- use_
storage_ entry - A hook that creates a StorageEntry with the latest value from storage or the init value if it doesn’t exist.
- use_
synced_ storage - A storage hook that can be used to store data that will persist across application reloads and be synced across all app sessions for a given installation or browser.
- use_
synced_ storage_ entry - A hook that creates a StorageEntry with the latest value from storage or the init value if it doesn’t exist, and provides a channel to subscribe to updates to the underlying storage.