zio.http.datastar

Members list

Type members

Classlikes

sealed trait CaseModifier extends Product, Serializable

Modifies how a Datastar attribute key is cased when rendered by the DSL.

Modifies how a Datastar attribute key is cased when rendered by the DSL.

Case modifiers contribute a __case.* suffix to attribute names when the selected case differs from the default case for that attribute builder.

Attributes

Companion
object
Source
CaseModifier.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object Camel
object Kebab
object Pascal
object Snake
object CaseModifier

Attributes

Companion
trait
Source
CaseModifier.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final class DataInit(val modifier: Maybe[InitModifier])

Builder for the data-init Datastar attribute.

Builder for the data-init Datastar attribute.

Modifiers such as delay and viewTransition are encoded into the final attribute name and normalized so repeated modifiers collapse to the last effective value. Use := to assign the Datastar expression that should run during initialization.

Attributes

Source
DataInit.scala
Supertypes
class Object
trait Matchable
class Any
final class DataOn(val eventName: String, val modifier: Maybe[EventModifier], val caseModifier: CaseModifier)

A data-on:* attribute builder with optional event modifiers.

A data-on:* attribute builder with optional event modifiers.

Chain modifiers like debounce, throttle, once, prevent, stop, capture, passive, outside, window, document, and viewTransition before assigning a handler with :=. Case modifiers (camel, kebab, snake, pascal) control attribute name casing. Repeated timing or target modifiers are normalized to the last effective value before the final attribute name is rendered.

Attributes

Source
DataOn.scala
Supertypes
class Object
trait Matchable
class Any
final class DataOnIntersect(val modifier: Maybe[IntersectModifier])

Builder for data-on-intersect Datastar attributes.

Builder for data-on-intersect Datastar attributes.

Visibility, timing, and transition modifiers are encoded into the final attribute name. Repeated modifiers are normalized to a single effective suffix. Use once, half, full, exit, threshold, delay, debounce, throttle, and viewTransition to model Datastar's supported intersection semantics.

Attributes

Source
DataOnIntersect.scala
Supertypes
class Object
trait Matchable
class Any
final class DataOnInterval(val modifier: Maybe[OnIntervalModifier])

Builder for data-on-interval Datastar attributes.

Builder for data-on-interval Datastar attributes.

Duration modifiers describe how often the interval fires, and durationLeading encodes Datastar's leading-edge interval variant. Repeated modifiers are normalized to the last effective duration. Use := to assign the expression executed on each interval tick.

Attributes

Source
DataOnInterval.scala
Supertypes
class Object
trait Matchable
class Any
final class DataOnSignalPatch(val modifier: Maybe[OnSignalPatchModifier])

Builder for data-on-signal-patch Datastar attributes.

Builder for data-on-signal-patch Datastar attributes.

Delay, debounce, and throttle modifiers are encoded into the final attribute name. Repeated timing modifiers are normalized to the last effective value. Use := to attach the Datastar expression that should run when a signal patch arrives.

Attributes

Source
DataOnSignalPatch.scala
Supertypes
class Object
trait Matchable
class Any
final class DataSignalsBuilder(val signalName: String, val caseModifier: CaseModifier)

Builds data-signals: attributes for a named signal key.

Builds data-signals: attributes for a named signal key.

The base key uses the kebab-cased signalName. Case modifier methods append a __case.* suffix when a non-default casing is requested. Values assigned with := must be valid Datastar expressions and become the attribute value rendered for that keyed signal.

Attributes

Source
DataSignalsBuilder.scala
Supertypes
class Object
trait Matchable
class Any
final class DatastarAttrKey(val name: String)

Low-level key for constructing Datastar data-* attributes directly.

Low-level key for constructing Datastar data-* attributes directly.

Most callers should prefer higher-level data* helpers from DatastarAttributes. Use DatastarAttrKey when defining a custom Datastar attribute name or when no dedicated helper exists yet. Values assigned with := are rendered through ToDatastarExpr, so expression contexts reject raw Scala String values in favor of explicit Datastar expressions.

Attributes

Companion
object
Source
DatastarAttrKey.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
DatastarAttrKey.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Mixin providing Datastar data-* attribute constructors for the HTML DSL.

Mixin providing Datastar data-* attribute constructors for the HTML DSL.

Typical usage is through the package object via import zio.http.datastar._. The methods in this trait build the Datastar attribute DSL surface, including signal initialization (dataSignals), bindings (dataBind), event handlers (dataOn), DOM updates (dataText, dataShow, dataClass, dataStyle, dataAttr), and lifecycle hooks (dataInit, dataOnIntersect, dataOnInterval, dataOnSignalPatch).

Attribute values are rendered as Datastar expressions, not as generic HTML string values. In expression positions use typed values such as Signal, SignalUpdate, DatastarRef, or explicit js"..." expressions.

Attributes

Source
DatastarAttributes.scala
Supertypes
class Object
trait Matchable
class Any
sealed trait DatastarEvent

A Datastar SSE event that can be sent to the browser.

A Datastar SSE event that can be sent to the browser.

Sealed trait with builder-style constructors in the companion object. Use DatastarEvent.patchElements, DatastarEvent.patchSignals, DatastarEvent.executeScript, or DatastarEvent.removeElements to create events, then call renderSSE to produce the SSE wire format. Builder options map directly to emitted SSE fields such as selector, mode, useViewTransition, namespace, id, and retry.

val sse = DatastarEvent.patchSignals(count := 42).eventId("evt-1").renderSSE

// event: datastar-patch-signals
// id: evt-1
// data: signals {"count":42}

Attributes

Companion
object
Source
DatastarEvent.scala
Supertypes
class Object
trait Matchable
class Any
object DatastarEvent

Attributes

Companion
trait
Source
DatastarEvent.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
object DatastarRef

Attributes

Companion
class
Source
DatastarRef.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final class DatastarRef

Attributes

Companion
object
Source
DatastarRef.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
ElementPatchMode.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ElementPatchMode extends Product, Serializable

Describes how Datastar should patch rendered content into the target element.

Describes how Datastar should patch rendered content into the target element.

Outer is the default patch mode and is omitted from SSE rendering.

Attributes

Companion
object
Source
ElementPatchMode.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object After
object Append
object Before
object Inner
object Outer
object Prepend
object Remove
object Replace
Show all
object EventModifier

Attributes

Companion
trait
Source
EventModifier.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait EventModifier extends Product, Serializable

Modifier ADT used by dataOn event bindings.

Modifier ADT used by dataOn event bindings.

Modifiers alter Datastar's event-handling semantics, such as debounce, throttle, delay, capture phase, and propagation/default handling. The rendered form is encoded directly into the attribute name. Composition via EventModifier.And preserves left-to-right ordering of suffixes.

Attributes

Companion
object
Source
EventModifier.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class And
object Capture
class Debounce
class Delay
object Document
object Once
object Outside
object Passive
object Prevent
object Stop
class Throttle
object Window
Show all
sealed trait EventType extends Product, Serializable

Datastar event types emitted via the SSE event: field.

Datastar event types emitted via the SSE event: field.

The rendered string returned by render is the protocol-level event name sent on the wire.

Attributes

Companion
object
Source
EventType.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object PatchElements
object PatchSignals
object EventType

Attributes

Companion
trait
Source
EventType.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
EventType.type
sealed trait InitModifier extends Product, Serializable

Modifier ADT used by data-init builders.

Modifier ADT used by data-init builders.

Init modifiers are encoded as __... suffixes and normalized so repeated delay or view-transition markers collapse to one effective form.

Attributes

Companion
object
Source
InitModifier.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class And
class Delay
object InitModifier

Attributes

Companion
trait
Source
InitModifier.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Source
IntersectModifier.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait IntersectModifier extends Product, Serializable

Modifier ADT used by data-on-intersect builders.

Modifier ADT used by data-on-intersect builders.

Intersect modifiers encode visibility thresholds, timing behavior, and view transitions into the attribute name. Composition preserves left-to-right ordering, while normalization collapses conflicting threshold/timing choices.

Attributes

Companion
object
Source
IntersectModifier.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class And
class Debounce
class Delay
object Exit
object Full
object Half
object Once
class Threshold
class Throttle
Show all

Attributes

Companion
trait
Source
OnIntervalModifier.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait OnIntervalModifier extends Product, Serializable

Modifier ADT used by data-on-interval builders.

Modifier ADT used by data-on-interval builders.

Interval modifiers encode the polling duration and optional view transition. Duration(..., leading = true) represents Datastar's leading-edge interval variant. Composition via OnIntervalModifier.And preserves the order of encoded suffixes before normalization removes redundant duration entries.

Attributes

Companion
object
Source
OnIntervalModifier.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class And
class Duration

Attributes

Companion
trait
Source
OnSignalPatchModifier.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait OnSignalPatchModifier extends Product, Serializable

Modifier ADT used by data-on-signal-patch builders.

Modifier ADT used by data-on-signal-patch builders.

Supported modifiers delay, debounce, or throttle reactions to incoming signal patches. Composition preserves left-to-right ordering and normalization keeps the last effective modifier of each timing family.

Attributes

Companion
object
Source
OnSignalPatchModifier.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class And
class Debounce
class Delay
class Throttle
final class PartialDataOn

Entry point for building data-on:* event handler attributes.

Entry point for building data-on:* event handler attributes.

Obtained via dataOn from DatastarAttributes. Select an event (click, submit, keydown, etc.) to get a DataOn builder, then assign a handler with :=. Use apply for custom event names.

dataOn.click := js"alert('hi')"
dataOn("custom-event").debounce(500) := count.ref

Attributes

Source
DataOn.scala
Supertypes
class Object
trait Matchable
class Any
final class Signal[A]

A named reactive signal for the Datastar frontend framework.

A named reactive signal for the Datastar frontend framework.

Represents a client-side signal identified by name. Signal names are validated at construction time. Literal names are checked at compile time, and dynamic names are checked at runtime. Names must be dot-separated JavaScript identifiers and must not contain __, which Datastar reserves for modifier syntax. Use := to create a SignalUpdate that pairs this signal with a JSON-serialized value.

val count = Signal[Int]("count")
count := 0  // SignalUpdate ready for patchSignals

Attributes

Companion
object
Source
Signal.scala
Supertypes
class Object
trait Matchable
class Any
object Signal

Attributes

Companion
class
Source
Signal.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Signal.type
final class SignalUpdate[A]

A signal name paired with its JSON-serialized value.

A signal name paired with its JSON-serialized value.

Created via Signal.:=. The name is the signal identifier and serialized is the JSON string produced by the signal's schema codec. Used by DatastarEvent.patchSignals to build SSE payloads and by the ToJs instance to render inline JavaScript object literals.

serialized is inserted verbatim into the final object expression, so it must already be valid JSON for the value being assigned.

Attributes

Companion
object
Source
SignalUpdate.scala
Supertypes
class Object
trait Matchable
class Any
object SignalUpdate

Attributes

Companion
class
Source
SignalUpdate.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait ToDatastarExpr[-A]

Attributes

Companion
object
Source
ToDatastarExpr.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
ToDatastarExpr.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Inherited methods

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala
def dataBind(signal: Signal[_]): Attribute

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala
def dataIndicator(signal: Signal[_]): Attribute

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala
def dataPreserveAttr(attrs: String*): Attribute

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala
def dataRef(name: String): Attribute

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala

Attributes

Inherited from:
DatastarAttributes
Source
DatastarAttributes.scala