pub fn use_persisted<'s, T: Serialize + DeserializeOwned + 'static>(
cx: &mut Cx<'s, '_>,
key: &str,
init: impl FnOnce() -> T,
) -> State<'s, T>Expand description
Hold T in the store and in the app’s storage, keyed by key.
Unlike every other hook the id comes from key alone, not from the call
site: a call site moves whenever the source is edited, and saved data has to
survive that (3.4). Two calls with the same key therefore share one value,
and calling it twice in one pass is a collision like any other.
The value is restored by crate::Store::load_persisted before the first
pass and written back by crate::Store::save_persisted; the runner wires
both to eframe’s storage.