solana_kit_subscribable library

Subscribable and observable patterns for the Solana Kit Dart SDK.

This package provides utilities for creating subscription-based event systems. It is the Dart port of the TypeScript @solana/subscribable package.

The primary components are:

  • ChannelStreamController - a stream-native named-channel controller for compatibility adapters.
  • createStreamFromDataAndErrorStreams - combines data and error streams into one broadcast stream.
  • demultiplexStream - splits a source stream into lazily subscribed typed channel streams.
  • DataPublisher / WritableDataPublisher - deprecated compatibility layers for the upstream TypeScript channel-publisher abstraction.

Prefer exposing Streams at package boundaries when writing new Dart APIs. Keep DataPublisher-based APIs only where they are still needed for compatibility with the upstream Solana Kit design.

Classes

ChannelStreamController
A typed, stream-native publisher for string-keyed compatibility channels.
DataPublisher
An object that publishes data to named channels.
ReactiveStore<T>
A small external-store facade over data and error streams.
StreamFromDataPublisherConfig
Configuration for createStreamFromDataPublisher.
WritableDataPublisher
A DataPublisher that also supports publishing data to channels.

Extensions

DataPublisherStreams on DataPublisher
Stream utilities for compatibility DataPublisher instances.

Functions

createAsyncIterableFromDataPublisher<TData>({required Future<void> abortSignal, required String dataChannelName, required DataPublisher dataPublisher, required String errorChannelName}) Stream<TData>
Creates a single-subscription Stream from a DataPublisher.
createDataPublisher() WritableDataPublisher
Creates a new WritableDataPublisher.
createReactiveStoreFromDataPublisher<T>({required DataPublisher dataPublisher, required String dataChannelName, required String errorChannelName}) ReactiveStore<T>
Creates a ReactiveStore backed by a DataPublisher.
createReactiveStoreFromStreams<T>({required Stream<T> dataStream, required Stream<Object?> errorStream}) ReactiveStore<T>
Creates a ReactiveStore backed by streams.
createStreamFromDataAndErrorStreams<TData>({required Stream<TData> dataStream, required Stream<Object?> errorStream}) Stream<TData>
Creates a broadcast stream from data and error streams.
createStreamFromDataPublisher<TData>(StreamFromDataPublisherConfig config) Stream<TData>
Creates a broadcast Stream from a DataPublisher.
demultiplexDataPublisher<TSourceData>({required DataPublisher sourcePublisher, required String sourceChannelName, required MessageTransformer<TSourceData> messageTransformer}) DataPublisher
Splits a single source channel of a DataPublisher into multiple derived channels using a messageTransformer.
demultiplexStream<TSourceData, TDestination>({required Stream<TSourceData> source, required String channelName, required MessageTransformer<TSourceData> messageTransformer}) Stream<TDestination>
Splits a stream into per-channel broadcast streams.

Typedefs

MessageTransformer<TSourceData> = (String, Object?)? Function(TSourceData message)
A function that transforms a source message into a destination channel name and message pair, or returns null to drop the message.
ReactiveStoreSubscriber = void Function()
A callback invoked when a ReactiveStore changes.
Subscriber<T> = void Function(T data)
A function that receives published data of type T.
UnsubscribeFn = void Function()
A function that unsubscribes a listener from a channel.