lightspeed/stream
LiveView-style stream compatibility helpers.
Types
Stream
opaqueStreaming collection state for one target container.
pub opaque type Stream
One stream entry keyed by stable id.
pub type StreamItem {
StreamItem(id: String, html: String)
}
Constructors
-
StreamItem(id: String, html: String)
Stream operation options compatible with LiveView semantics.
pub type StreamOptions {
StreamOptions(at: Int, limit: option.Option(Int), reset: Bool)
}
Constructors
-
StreamOptions(at: Int, limit: option.Option(Int), reset: Bool)
Values
pub fn options() -> StreamOptions
Default stream options:
- at: -1 (append)
- limit: none
- reset: false
pub fn stream(
stream_state: Stream,
incoming: List(StreamItem),
options: StreamOptions,
) -> #(Stream, List(diff.Patch))
Apply stream/4 semantics.
pub fn stream_delete(
stream_state: Stream,
entry_id: String,
) -> #(Stream, List(diff.Patch))
Apply stream_delete/2 semantics.
pub fn stream_insert(
stream_state: Stream,
entry: StreamItem,
at: Int,
limit: option.Option(Int),
) -> #(Stream, List(diff.Patch))
Apply stream_insert/4 semantics.
pub fn with_at(options: StreamOptions, at: Int) -> StreamOptions
Override insertion position.
pub fn with_limit(
options: StreamOptions,
limit: Int,
) -> StreamOptions
Override stream limit. Positive keeps first N; negative keeps last N.
pub fn with_reset(
options: StreamOptions,
reset: Bool,
) -> StreamOptions
Override reset behavior.