Skip to main content

ContextKey

Trait ContextKey 

Source
pub trait ContextKey: 'static {
    type Value: 'static;
}
Expand description

A typed, namespaced key for a value supplied by a component or application. Distinct key types can provide the same value type without colliding.

use fusor::{ContextKey, Owner, Signal, signal};
struct Locale;
impl ContextKey for Locale { type Value = Signal<String>; }
let app = Owner::new();
app.handle().provide::<Locale>(signal("en".to_owned())).unwrap();
let child = Owner::child(&app.handle());
assert_eq!(child.handle().context::<Locale>().unwrap().get(), "en");

Required Associated Types§

Source

type Value: 'static

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§