Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline
GitHub
c

LiveStreamDef

class LiveStreamDef[A, Id]

Defines the identity and optional retention policy of a LiveView stream.

A stream is keyed by name within its owning LiveView or LiveComponent. Reuse the same definition value, or a retention-adjusted value derived from it, throughout the lifecycle. The runtime rejects a separately constructed definition for an existing stream name.

Every item must produce a stable, non-empty DOM id that is unique within the stream and, as an HTML invariant, within the rendered document. Equal ids identify the same stream entry and cause an in-place update rather than a second row. Changing an item's id does not delete its old row. The runtime rejects an empty name, an empty generated id, a throwing id or domId, an invalid position, or a non-positive limit when an operation uses the definition; construction itself is unchecked.

Type parameters

A

the stream item type

Id

the stable domain identity type used to address items

Parameters

name

non-empty runtime key and the container id used by the renderIn helper

id

stable function selecting an item's domain identity

domId

stable function assigning each domain identity its row DOM id

limit

optional retention limit applied by creation, reset, and insertion operations, defaulting to no limit

Exported from scalive.streams.LiveStreamDef. View source (scalive/api/src/scalive/streams/LiveStream.scala:73-103)

Methods4

keepFirst

def keepFirst(count: Int): LiveStreamDef[A, Id]

Returns a copy that retains at most the first count items.

Validation that count is positive is deferred until an operation applies the limit.

Exported from scalive.streams.LiveStreamDef.keepFirst. View source (scalive/api/src/scalive/streams/LiveStream.scala:83-84)

keepLast

def keepLast(count: Int): LiveStreamDef[A, Id]

Returns a copy that retains at most the last count items.

Validation that count is positive is deferred until an operation applies the limit.

Exported from scalive.streams.LiveStreamDef.keepLast. View source (scalive/api/src/scalive/streams/LiveStream.scala:90-91)

withLimit

def withLimit(limit: Option[StreamLimit]): LiveStreamDef[A, Id]

Returns a copy using limit; None disables retention pruning.

Limit validation is deferred until an operation applies the limit.

Exported from scalive.streams.LiveStreamDef.withLimit. View source (scalive/api/src/scalive/streams/LiveStream.scala:97-98)

withoutLimit

def withoutLimit: LiveStreamDef[A, Id]

Returns a copy with no retention limit.

Exported from scalive.streams.LiveStreamDef.withoutLimit. View source (scalive/api/src/scalive/streams/LiveStream.scala:101-102)

Values4

domId

val domId: Id => String

Stable function assigning each domain identity its row DOM id.

Exported from scalive.streams.LiveStreamDef.domId. View source (scalive/api/src/scalive/streams/LiveStream.scala:76-76)

id

val id: A => Id

Stable function selecting an item's domain identity.

Exported from scalive.streams.LiveStreamDef.id. View source (scalive/api/src/scalive/streams/LiveStream.scala:75-75)

limit

val limit: Option[StreamLimit]

Optional retention limit applied by creation, reset, and insertion operations, defaulting to no limit.

Exported from scalive.streams.LiveStreamDef.limit. View source (scalive/api/src/scalive/streams/LiveStream.scala:77-77)

name

val name: String

Non-empty runtime key and the container id used by the renderIn helper.

Exported from scalive.streams.LiveStreamDef.name. View source (scalive/api/src/scalive/streams/LiveStream.scala:74-74)