pub struct GSlot {}Expand description
An interface for providing Dora SSR built-in global event names.
Implementations§
Source§impl GSlot
impl GSlot
Sourcepub const APP_EVENT: &'static str = "AppEvent"
pub const APP_EVENT: &'static str = "AppEvent"
Triggers when the application receives an event.
§Callback Arguments
- event_type: string - The type of the application event. The event type could be “Quit”, “LowMemory”, “WillEnterBackground”, “DidEnterBackground”, “WillEnterForeground”, “DidEnterForeground”.
§Callback Example
node.gslot(GSlot::APP_EVENT, Box::new(|stack| {
let event_type = match stack.pop_str() {
Some(event_type) => event_type,
None => return,
};
p!(event_type);
}));Sourcepub const APP_CHANGE: &'static str = "AppChange"
pub const APP_CHANGE: &'static str = "AppChange"
Triggers when the application settings change.
§Callback Arguments
- setting_name: string - The name of the setting that changed. Could be “Locale”, “Theme”, “FullScreen”, “Position”, “Size”.
§Callback Example
node.gslot(GSlot::APP_CHANGE, Box::new(|stack| {
let setting_name = match stack.pop_str() {
Some(setting_name) => setting_name,
None => return,
};
p!(setting_name);
}));Sourcepub const APP_WS: &'static str = "AppWS"
pub const APP_WS: &'static str = "AppWS"
Triggers when gets an event from a websocket connection.
§Callback Arguments
- event_type: string - The event type of the message received. Could be “Open”, “Close”, “Send”, “Receive”.
- msg: string - The message received.
§Callback Example
node.gslot(GSlot::APP_WS, Box::new(|stack| {
let (
event_type,
msg
) = match (stack.pop_str(), stack.pop_str()) {
(Some(event_type), Some(msg)) => (event_type, msg),
_ => return,
};
p!(event_type, msg);
}));Sourcepub fn on_app_event<F>(node: &mut dyn INode, callback: F)
pub fn on_app_event<F>(node: &mut dyn INode, callback: F)
Registers a callback for event triggered when the application receives an event.
§Arguments
- node: &mut dyn INode - The node to register the callback on.
- callback: F - The callback to be called when the event is triggered with the following arguments:
- event_type: String - The type of the application event. The event type could be “Quit”, “LowMemory”, “WillEnterBackground”, “DidEnterBackground”, “WillEnterForeground”, “DidEnterForeground”.
Sourcepub fn on_app_change<F>(node: &mut dyn INode, callback: F)
pub fn on_app_change<F>(node: &mut dyn INode, callback: F)
Registers a callback for event triggered when the application settings change.
§Arguments
- node: &mut dyn INode - The node to register the callback on.
- callback: F - The callback to be called when the event is triggered with the following arguments:
- setting_name: String - The name of the setting that changed. Could be “Locale”, “Theme”, “FullScreen”, “Position”, “Size”.
Sourcepub fn on_app_ws<F>(node: &mut dyn INode, callback: F)
pub fn on_app_ws<F>(node: &mut dyn INode, callback: F)
Registers a callback for event triggered when gets an event from a websocket connection.
§Arguments
- node: &mut dyn INode - The node to register the callback on.
- callback: F - The callback to be called when the event is triggered with the following arguments:
- event_type: String - The event type of the message received. Could be “Open”, “Close”, “Send”, “Receive”.
- msg: String - The message received.
Auto Trait Implementations§
impl Freeze for GSlot
impl RefUnwindSafe for GSlot
impl Send for GSlot
impl Sync for GSlot
impl Unpin for GSlot
impl UnwindSafe for GSlot
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
Mutably borrows from an owned value. Read more