datastar_gleam/consts

Types

How the server-sent HTML fragment should be inserted relative to the matched element.

pub type ElementPatchMode {
  Outer
  Inner
  Remove
  Replace
  Prepend
  Append
  Before
  After
}

Constructors

  • Outer

    Replace the outer HTML of the matched element.

  • Inner

    Replace the inner HTML of the matched element.

  • Remove

    Remove the matched element from the DOM.

  • Replace

    Replace the matched element entirely.

  • Prepend

    Insert the fragment before the first child of the matched element.

  • Append

    Insert the fragment after the last child of the matched element.

  • Before

    Insert the fragment immediately before the matched element.

  • After

    Insert the fragment immediately after the matched element.

The two top-level event types that Datastar recognises.

pub type EventType {
  PatchElements
  PatchSignals
}

Constructors

  • PatchElements

    Patch one or more DOM elements.

  • PatchSignals

    Patch the reactive signal store.

Values

pub const datastar_key: String

Constants, enums, and default values used across the Datastar SDK. The Datastar library name.

pub const datastar_req_header: String

The HTTP header that marks a request as coming from the Datastar frontend.

pub const default_elements_use_view_transitions: Bool
pub const default_patch_signals_only_if_missing: Bool
pub const default_sse_retry_duration: Int

Default SSE reconnection time in milliseconds.

pub fn element_patch_mode_string(
  mode: ElementPatchMode,
) -> String

Return the wire-format string for a patch mode.

pub const elements_literal: String
pub fn event_type_string(event: EventType) -> String

Return the SSE event name for an EventType.

pub const mode_literal: String
pub const only_if_missing_literal: String
pub const selector_literal: String
pub const signals_literal: String
pub const use_view_transition_literal: String
pub const version: String

SDK version (matches the Datastar version this SDK targets).

Search Document