Struct GSlot

Source
pub struct GSlot {}
Expand description

An interface for providing Dora SSR built-in global event names.

Implementations§

Source§

impl GSlot

Source

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);
}));
Source

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);
}));
Source

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);
}));
Source

pub fn on_app_event<F>(node: &mut dyn INode, callback: F)
where F: FnMut(String) + 'static,

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”.
Source

pub fn on_app_change<F>(node: &mut dyn INode, callback: F)
where F: FnMut(String) + 'static,

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”.
Source

pub fn on_app_ws<F>(node: &mut dyn INode, callback: F)
where F: FnMut(String, String) + 'static,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.