Crate dioxus_sdk_storage

Crate dioxus_sdk_storage 

Source
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§

LocalStorage
SessionStorage
StorageChannelPayload
A payload for a storage channel that contains the latest value from storage.
StorageEntry
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.
StorageSubscription
A struct to hold information about processing a storage event.
SyncedStorageEntry
A wrapper around StorageEntry that provides a channel to subscribe to updates to the underlying storage.

Traits§

StorageBacking
A trait for a storage backing
StorageEntryTrait
A trait for common functionality between StorageEntry and SyncedStorageEntry
StorageSubscriber
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.