API
There are two variants to implement channels: ReactiveChannel
and ReactiveFunctionalChannel
.
tip
Use the first variant when you want to use your class for channels.
tip
Use the second variant when you want to implement only some functions using function objects.
ReactiveChannelโ
Declaration
class ReactiveChannel {
String get key
ReactiveChannelConfiguration get configuration
FutureOr<void> onPayload(dynamic payload, ReactiveProducer producer)
FutureOr<void> onComplete(ReactiveProducer producer)
FutureOr<void> onCancel(ReactiveProducer producer)
FutureOr<void> onSubscribe(ReactiveProducer producer)
FutureOr<void> onError(int code, String error, ReactiveProducer producer)
FutureOr<void> onRequest(int count, ReactiveProducer producer)
}
ReactiveFunctionalChannelโ
Declaration
class ReactiveFunctionalChannel with ReactiveChannel {
final String key
final ReactiveChannelConfiguration configuration
final FutureOr<void> Function(dynamic payload, ReactiveProducer producer)? payloadConsumer
final FutureOr<void> Function(ReactiveProducer producer)? subscribeConsumer
final FutureOr<void> Function(int code, String error, ReactiveProducer producer)? errorConsumer
final FutureOr<void> Function(int count, ReactiveProducer producer)? requestConsumer
final FutureOr<void> Function(ReactiveProducer producer)? completeConsumer
final FutureOr<void> Function(ReactiveProducer producer)? cancelConsumer
ReactiveFunctionalChannel(
this.key,
this.configuration, {
required this.payloadConsumer,
required this.subscribeConsumer,
required this.errorConsumer,
required this.requestConsumer,
required this.completeConsumer,
required this.cancelConsumer,
});
FutureOr<void> onError(int code, String error, ReactiveProducer producer)
FutureOr<void> onPayload(dynamic payload, ReactiveProducer producer)
FutureOr<void> onRequest(int count, ReactiveProducer producer)
FutureOr<void> onSubscribe(ReactiveProducer producer)
FutureOr<void> onComplete(ReactiveProducer producer)
FutureOr<void> onCancel(ReactiveProducer producer)
}
Propertiesโ
keyโ
Channel identifier between server and client.
configurationโ
Specific parameters for the single channel.
Methodsโ
onPayloadโ
Called when a payload was received.
onCompleteโ
Called when a complete event was received.
onCancelโ
Called when a cancel event was received.
onSubscribeโ
Called when a channel was subscribed.
onErrorโ
Called when an error was received.
onRequestโ
Called when a channel wants more payloads.
Referencesโ
- See ReactiveProducer