Skip to main content

LiveView

classpond-tssource

Constructor

new LiveView(source: LiveSource<any>, process: (event: any) => EventForSchema<S> | undefined, options?: ViewOptions<S>)

Properties

namestringreadonly
schemaSreadonly
lengthnumberreadonly

Methods

aggregate

aggregate(sequence: Sequence, mapping: M): LiveAggregation<S, readonly [ColumnDef<'interval', 'interval'>, AggregateColumns<ValueColumnsForSchema<S>, M>]>

at

at(index: number): EventForSchema<S> | undefined

atOrAfter

atOrAfter(key: KeyLike): EventForSchema<S> | undefined
view.atOrAfter(new Time(t))

atOrBefore

atOrBefore(key: KeyLike): EventForSchema<S> | undefined
view.atOrBefore(new Time(t))

bisect

bisect(key: KeyLike): number
view.bisect(new Time(t))

Insertion index for key in the sorted view buffer (binary search).

column

column(name: Name): ChunkedFloat64Column | Float64Column
view.column('cpu').toFloat64Array()

Gathers a numeric value column from the view's current events. Restricted to numeric columns (the chart-feed case) — string / array columns are rejected at compile time; read the partition key as a scalar via at(i).get(name), or toTimeSeries() for full kind coverage.

count

count(): number
live.window('1m').count()

Returns the number of events currently in the view's buffer. For windows created via window(duration), this is "events in the last N seconds"; for window(count), it's "events in the last N retained."

Cheap O(1) accessor that reads this.length directly — same value as view.length. Provided as a method so it composes naturally with LiveView.rate.

cumulative

cumulative(spec: { [K in string]: 'sum' | 'min' | 'max' | 'count' | (acc: number, value: number) => number }): LiveView<readonly [S[0], ReplaceSmoothedColumn<ValueColumnsForSchema<S>, Targets>]>

diff

diff(columns: Target | readonly Target[], options?: { drop?: boolean }): LiveView<readonly [S[0], ReplaceSmoothedColumn<ValueColumnsForSchema<S>, Target>]>

dispose

dispose(): void

Detach this view from its source and drop its own listeners. After dispose() the view stops receiving events; its buffer is left as it was (a final toTimeSeries() snapshot still works) and further dispose() calls are no-ops.

Chain-aware. live.filter(p).map(f) creates an intermediate view that nothing but the outer view references, and before [PND-LIVFIX] disposing the outer view left that intermediate subscribed to the source forever, processing every push into an unbounded buffer with no handle to stop it (audit 2026-06 §4.4). Now, when this view's source is itself a LiveView and this was its last subscriber, the source is disposed too, and so on up the chain. A source view that still has another subscriber is left alone. If you hold a reference to an intermediate and want to keep reading it after disposing a derived view, keep a listener on it — a view with no subscribers is treated as unreachable.

eventRate

eventRate(): number
live.window('1m').eventRate()

Returns events per second over the view's window — count() / windowSeconds.

Only defined on time-based windows. Throws on count-based windows (window(100)) and on views that weren't created by a .window(duration) call (filter / map / select on a non-windowed source — there's no denominator to use).

Convenient for metrics-endpoint gauges and React displays ("EVENT RATE 8.0/s"). Pairs with LiveView.count for cases where both numbers are needed.

Distinct from LiveView.rate, which is the per-column derivative operator (rate-of-change of values). eventRate is per-window-events-per-second; rate(columns) is per-event derivative of the named columns.

every

every(predicate: (event: EventForSchema<S>, index: number) => boolean): boolean
view.every(e => e.get('healthy'))

fill

fill(strategy: LiveFillStrategy | LiveFillMapping<S>, options?: { limit?: number }): LiveView<S>

filter

filter(predicate: (event: EventForSchema<S>) => boolean): LiveView<S>

find

find(predicate: (event: EventForSchema<S>, index: number) => boolean): EventForSchema<S> | undefined
view.find(e => e.get('value') > 0)

first

first(): EventForSchema<S> | undefined

includesKey

includesKey(key: KeyLike): boolean
view.includesKey(new Time(t))

keyColumn

keyColumn(): TimeKeyOnly<S>
view.keyColumn().begin

Gathers the time axis into a TimeKeyColumn directly from the view's current events. Time-keyed series only.

last

last(): EventForSchema<S> | undefined

map

map(fn: (event: EventForSchema<S>) => EventForSchema<S>): LiveView<S>

Per-event transform. Each source event is run through fn and the result is appended to the view's buffer. The view does NOT re-sort by key — events flow through in source order, which preserves the upstream's sort invariant only if fn returns events with the same key.

If fn rewrites the event's key (e.g. shifting timestamps, changing the interval), the view's buffer is no longer key-sorted. The Tier 2 query primitives (LiveView.bisect, LiveView.includesKey, LiveView.atOrBefore, LiveView.atOrAfter) all assume sorted-by-key and will return wrong answers on a re-keying map. Use map only for data transforms; use a separate live primitive for time-axis transforms.

on

on(type: 'event', fn: EventListener<S>): () => void
on(type: 'evict', fn: EvictListener<S>): () => void

partitionBy

partitionBy(col: Col): { toMap: unknown }

Walk-now partition read. Buckets the view's current events by col and runs fn over each partition's column view, returning a Map keyed by the partition value (normalized to a string, matching TimeSeries.partitionBy(col).toMap(fn)) — but skipping the per-partition TimeSeries construction (gathers only the columns fn reads). Distinct from LiveSeries.partitionBy, which is subscription-oriented (live sub-series); this is a snapshot-style read of the current window.

pctChange

pctChange(columns: Target | readonly Target[], options?: { drop?: boolean }): LiveView<readonly [S[0], ReplaceSmoothedColumn<ValueColumnsForSchema<S>, Target>]>

rate

rate(columns: Target | readonly Target[], options?: { drop?: boolean }): LiveView<readonly [S[0], ReplaceSmoothedColumn<ValueColumnsForSchema<S>, Target>]>

reduce

reduce(mapping: M, options?: LiveRollingOptions): LiveReduce<S, readonly [S[0], AggregateColumns<ValueColumnsForSchema<S>, M>]>

Streaming reduce over the view's current buffer. See LiveSeries.reduce for the full surface.

rolling

rolling(window: RollingWindow, mapping: M, options?: LiveRollingOptions): LiveRollingAggregation<S, readonly [S[0], AggregateColumns<ValueColumnsForSchema<S>, M>]>
rolling(fusedMapping: FM & FusedMappingValid<FM>, options?: LiveRollingOptions): LiveFusedRolling<S, readonly [S[0], FusedRollingColumns<S, FM>]>

Keyed-form fused multi-window rolling on a LiveView. See LiveSeries.rolling for the full surface — chained-from- a-view behavior is identical to the same call on a top-level LiveSeries.

sample

sample(strategy: SampleStrategy): LiveView<S>

Bounded-memory stream sampling on a LiveView. Same semantics as LiveSeries.sample — stride only on the live side in v0.17.0.

Multi-entity bias trap applies here too: a LiveView derived from a multi-entity source carries the same bias risk. Chain after partitionBy(...) for the safe-by-construction shape; see LiveSeries.sample for the full discussion.

select

select(keys: Keys): LiveView<readonly [S[0], PickSelectedColumns<ValueColumnsForSchema<S>, Keys[number]>]>

some

some(predicate: (event: EventForSchema<S>, index: number) => boolean): boolean
view.some(e => e.get('healthy'))

toTimeSeries

toTimeSeries(name?: string): TimeSeries<S>

window

window(size: RollingWindow): LiveView<S>