Module: Solana::Ruby::Kit::Subscribable
- Extended by:
- T::Sig
- Defined in:
- lib/solana/ruby/kit/subscribable.rb,
lib/solana/ruby/kit/subscribable/async_iterable.rb,
lib/solana/ruby/kit/subscribable/data_publisher.rb,
lib/solana/ruby/kit/subscribable/reactive_action_store.rb,
lib/solana/ruby/kit/subscribable/reactive_stream_store.rb
Defined Under Namespace
Modules: AsyncIterable Classes: DataPublisher, ReactiveActionState, ReactiveActionStore, ReactiveState, ReactiveStreamStore, RetryableReactiveStreamStore
Constant Summary collapse
- ReactiveActionStatus =
Lifecycle status of a ReactiveActionStore. Mirrors TypeScript’s ReactiveActionStatus.
T.type_alias { String }
- REACTIVE_ACTION_IDLE_STATE =
T.let( ReactiveActionState.new(status: 'idle').freeze, ReactiveActionState )
- REACTIVE_LOADING_STATE =
T.let( ReactiveState.new(status: 'loading').freeze, ReactiveState )
- ReactiveStore =
Deprecated alias — use ReactiveStreamStore.
ReactiveStreamStore
Class Method Summary collapse
- .create_reactive_action_store(&fn) ⇒ Object
- .create_reactive_store_from_data_publisher(publisher, data_channel:, error_channel:, signal: nil) ⇒ Object
- .create_reactive_store_from_data_publisher_factory(data_channel:, error_channel:, signal: nil, &blk) ⇒ Object
Class Method Details
.create_reactive_action_store(&fn) ⇒ Object
203 204 205 |
# File 'lib/solana/ruby/kit/subscribable/reactive_action_store.rb', line 203 def create_reactive_action_store(&fn) ReactiveActionStore.new(T.let(fn, T.proc.params(args: T.untyped).returns(T.untyped))) end |
.create_reactive_store_from_data_publisher(publisher, data_channel:, error_channel:, signal: nil) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 216 def create_reactive_store_from_data_publisher(publisher, data_channel:, error_channel:, signal: nil) store = ReactiveStreamStore.new publisher.on(data_channel, signal: signal) do |data| store._set_state(ReactiveState.new(status: 'loaded', data: data)) end publisher.on(error_channel, signal: signal) do |err| unified = store.get_unified_state next if unified.status == 'error' store._set_state(ReactiveState.new(status: 'error', data: unified.data, error: err)) end store end |
.create_reactive_store_from_data_publisher_factory(data_channel:, error_channel:, signal: nil, &blk) ⇒ Object
244 245 246 247 248 249 250 251 252 253 |
# File 'lib/solana/ruby/kit/subscribable/reactive_stream_store.rb', line 244 def create_reactive_store_from_data_publisher_factory( data_channel:, error_channel:, signal: nil, &blk ) RetryableReactiveStreamStore.new( data_channel: data_channel, error_channel: error_channel, create_publisher: T.let(blk, T.proc.returns(DataPublisher)), signal: signal ) end |