euv-example 0.5.34

An example application demonstrating the euv UI framework with reactive signals, custom components, and WebAssembly.
Documentation
use crate::*;

/// A single WebSocket message with its display text and timestamp.
#[derive(Clone, PartialEq)]
pub(crate) struct WsMessage {
    /// The display text extracted from the JSON `data` field.
    pub(crate) data: String,
    /// The formatted time string extracted from the JSON `time` field.
    pub(crate) time: String,
}

/// The server-sent WebSocket message format for deserialization.
///
/// Example JSON: `{"type":"Text","name":"uuid","data":"hello","time":1780741281040}`
#[derive(Clone, Deserialize)]
pub(crate) struct WsServerMessage {
    /// The message payload.
    pub(crate) data: String,
    /// The millisecond timestamp when the message was sent.
    pub(crate) time: f64,
}

/// Reactive state for the WebSocket demo page.
#[derive(Clone, Copy, Data)]
pub(crate) struct UseWebSocket {
    /// The WebSocket endpoint URL input.
    #[get(type(copy))]
    pub(crate) url: Signal<String>,
    /// Whether the WebSocket connection is currently active.
    #[get(type(copy))]
    pub(crate) connected: Signal<bool>,
    /// Whether the WebSocket connection is currently being established.
    #[get(type(copy))]
    pub(crate) connecting: Signal<bool>,
    /// The WebSocket message input.
    #[get(type(copy))]
    pub(crate) message_input: Signal<String>,
    /// The received WebSocket messages.
    #[get(type(copy))]
    pub(crate) messages: Signal<Vec<WsMessage>>,
    /// The error message, empty if no error.
    #[get(type(copy))]
    pub(crate) error: Signal<String>,
    /// The interval handle for the Ping keep-alive timer.
    #[get(type(copy))]
    pub(crate) ping_handle: Signal<Option<IntervalHandle>>,
}