pub struct MenuEvents {
pub latest: RwSignal<Option<MenuEvent>>,
}Expand description
The menu-activation read surface (frust-reactive’s process-wide menu
source — see its module docs): a per-OS desktop shell drains its native menu
queue once per frame and reports each activation, and app code observes it
here. menu_events() returns the live MenuEvents handle whose latest
signal carries a MenuEvent — the activated item’s id exactly as the
app wrote it in its MenuSpec, plus a monotonic sequence so choosing
the same item twice reads as two activations rather than one stale value.
use frust::{AnyView, Component, Get, any, menu_events, text};
#[derive(Default)]
struct MenuDemo;
impl Component for MenuDemo {
type State = ();
fn init(&self) -> Self::State {}
fn build(&self, _state: &mut Self::State) -> AnyView<Self::State> {
// A tracked read: this rebuild re-runs when an item is activated.
let label = match menu_events().latest.get() {
Some(event) => format!("chose {}", event.id),
None => "nothing chosen yet".to_string(),
};
any(text(label))
}
}Available on every target, unlike the MenuSpec vocabulary that
describes the menu itself: a component reading menu events compiles on
Android/iOS too (where nothing ever pushes one), so shared component code
needs no cfg of its own.
Unlike push_deep_link, the push side is deliberately not
re-exported: a menu activation has exactly one producer — the per-OS shell
that owns the platform menu — and nothing in an app simulates one the way
examples/navdemo simulates a warm deep link.
The app-facing menu-activation read surface. Obtained via menu_events
(frust::menu_events() at the facade).
Fields§
§latest: RwSignal<Option<MenuEvent>>The most recently activated item, or None when nothing has been
activated in this process yet. Read/track it with the Get/Track
traits (frust::{Get, Track}) the same way any other RwSignal is read.
There is deliberately no initial-style snapshot beside it (the
deep-link source’s cold-start half): a menu cannot be activated before
the app it belongs to is running, so “the first activation ever” carries
no precedence meaning worth recording.
Trait Implementations§
Source§impl Clone for MenuEvents
impl Clone for MenuEvents
Source§fn clone(&self) -> MenuEvents
fn clone(&self) -> MenuEvents
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MenuEvents
impl RefUnwindSafe for MenuEvents
impl Send for MenuEvents
impl Sync for MenuEvents
impl Unpin for MenuEvents
impl UnsafeUnpin for MenuEvents
impl UnwindSafe for MenuEvents
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.