Stores passive data that can be accessed in event handlers of multiple activities.
A Domain stores arbitrary data for sharing between multiple Activities. Library users can define the number of domains but each activity can only join one domain.
Domains should only be used when data needs to be shared between multiple activities of the same or different types. If data is only used by a single activity, it is usually better to store it in the activity struct itself.
In case only one domain is used, you can also consider to use
DefaultDomain instead of creating your own enum.
For now, there is no real benefit from using multiple Domains, other than data isolation. But there are plans for the future that will schedule Activities in different threads, based on their domain.
Stores a value in the domain. Only one instance per type id can be stored inside a domain. If an old value of the same type already exists in the domain, it will be overwritten.
Returns a reference to a value of the specified type, if such a value has previously been stored to the domain.
pub fn try_get_mut<T: Any>(&mut self) -> Option<&mut T>[src]
try_get but grants mutable access to the object.
Return two mutable references to domain objects
Returns a reference to a value of the specified type, taken from the domain.
Panics if object of that type has not been stored previously.
try_get() is usually recommended instead.
impl !RefUnwindSafe for DomainState
impl !Send for DomainState
impl !Sync for DomainState
impl Unpin for DomainState
impl !UnwindSafe for DomainState
type Error = Infallible
The type returned in the event of a conversion error.