Class: Solana::Ruby::Kit::Subscribable::ReactiveState

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/solana/ruby/kit/subscribable/reactive_stream_store.rb

Overview

Lifecycle snapshot of a ReactiveStreamStore — a single frozen value capturing status, last-known data, and any error.

status values:

'loading'  — waiting for first value; data is nil
'loaded'   — value has arrived, no active error
'error'    — stream failed; data is last known value (may be nil)
'retrying' — retry in progress after error; data preserved

Mirrors TypeScript’s ReactiveState<T>.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, data: nil, error: nil) ⇒ ReactiveState

Returns a new instance of ReactiveState.



34
35
36
37
38
39
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 34

def initialize(status:, data: nil, error: nil)
  @status = T.let(status, String)
  @data   = T.let(data,   T.untyped)
  @error  = T.let(error,  T.untyped)
  freeze
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



28
29
30
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 28

def data
  @data
end

#errorObject (readonly)

Returns the value of attribute error.



31
32
33
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 31

def error
  @error
end

#statusObject (readonly)

Returns the value of attribute status.



25
26
27
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 25

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
45
46
47
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 42

def ==(other)
  other.is_a?(ReactiveState) &&
    @status == other.status &&
    @data.equal?(other.data) &&
    @error.equal?(other.error)
end