class

Spacetime::TableCache(T)

Inherits Enumerable < Spacetime::AbstractTableCache < Reference < Object

Strongly-typed reactive client-side cache for a SpacetimeDB table T.

Automatically reconciles row insertions, deletions, and primary-key updates from InitialSubscription, SubscribeApplied, and TransactionUpdate messages.

Constructors

new(custom_name : String | Nil = nil)
Source

Instance methods

[](pk) : T
Source
apply_table_update(update : Protocol::TableUpdate) : Nil

Applies a Protocol::TableUpdate (from BSATN or SATS-JSON) and triggers reactive callbacks.

Source
clear
Source
count
Source
each

Must yield this collection's elements to the block.

Source
empty?

Returns true if self does not contain any element.

([] of Int32).empty? # => true
([1]).empty?         # => false
[nil, false].empty?  # => false
  • #present? returns the inverse.
Source
filter
Source
find_by_pk(pk) : T | Nil

Looks up a row by its @[Spacetime::PrimaryKey] value.

Source
on_delete
Source
on_insert
Source
on_update
Source
size

Returns the number of elements in the collection.

[1, 2, 3, 4].size # => 4
Source
table_name
Source