SseParsedSourceController<T> class
final
Implementation of SseSourceControllerBase where the onErrorEvent
and eventParser action can be specified in parameter,
allowing configuration of reconnection logic and parsing of
each event into a specified object type.
If you don't need to specify a custom object for the stream, use SseSourceController.
If you need more precise control prefer implementing SseSourceControllerBase
- Inheritance
-
- Object
- StreamSourceController<
T> - SseSourceControllerBase<
T> - SseParsedSourceController
Constructors
-
SseParsedSourceController({required String name, required ConnectionStreamBuilder sseStreamBuilder, required FutureOr<
T> eventParser(Map<String, dynamic> event), bool isBroadCast = false, bool doDisposeOnCancel = true, bool doDisposeOnClientException = false, dynamic onNewConnection(String name)?, dynamic onConnected(String name)?, dynamic onCloseConnection(String name, bool wasConnected)?, dynamic onCancel(String name, bool wasConnected)?, ParsedEventErrorAction? actionOnErrorEvent}) -
Implementation of SseSourceControllerBase where the
onErrorEventandeventParseraction can be specified in parameter, allowing configuration of reconnection logic and parsing each event to specified object type.
Properties
- doDisposeOnCancel ↔ bool
-
Whether to dispose the controller when cancelled.
getter/setter pairinherited
- done → Future
-
A future which is completed when the stream controller is done
sending events.
no setterinherited
-
eventParser
↔ FutureOr<
T> Function(Map<String, dynamic> event) -
getter/setter pair
-
eventStreamController
→ StreamController<
T> -
Internal event stream controller
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListener → bool
-
Whether there is a subscriber on the Stream.
no setterinherited
- isClosed → bool
-
Whether the stream controller is closed for adding more events.
no setterinherited
- isConnected → bool
-
Returns true if the connection is currently listened to.
no setterinherited
- isPaused → bool
-
Whether the subscription would need to buffer events.
no setterinherited
- name → String
-
The name of the SSE subscription.
finalinherited
- onCancel ↔ FutureOr Function()?
-
The callback which is called when the stream is canceled.
getter/setter pairinherited
- onCancelConnection ↔ dynamic Function(String name, bool wasConnected)?
-
Callback for when the controller is cancelled.
getter/setter pairinherited
- onCloseConnection ↔ dynamic Function(String name, bool wasConnected)?
-
Callback for when a connection is closed.
getter/setter pairinherited
- onConnected ↔ dynamic Function(String name)?
-
Callback for when a connection is established.
getter/setter pairinherited
- onListen ↔ void Function()?
-
The callback which is called when the stream is listened to.
getter/setter pairinherited
- onNewConnection ↔ dynamic Function(String name)?
-
Callback for when a new connection is created.
getter/setter pairinherited
- onPause ↔ void Function()?
-
The callback which is called when the stream is paused.
getter/setter pairinherited
- onResume ↔ void Function()?
-
The callback which is called when the stream is resumed.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sink
→ StreamSink<
T> -
Returns a view of this object that only exposes the StreamSink interface.
no setterinherited
-
stream
→ Stream<
T> -
The stream that this controller is controlling.
no setterinherited
- wasConnected → bool
-
no setterinherited
Methods
-
add(
T event) → void -
Sends a data
event.inherited -
addError(
Object error, [StackTrace? stackTrace]) → void -
Sends or enqueues an error event.
inherited
-
addStream(
Stream< T> source, {bool? cancelOnError}) → Future -
Receives events from
sourceand puts them into this controller's stream.inherited -
clear(
) → Future< void> -
Cancel the current HTTP event stream subscription and close the client.
inherited
-
close(
) → Future -
Closes the stream.
inherited
-
closeClient(
) → void -
Closes the HTTP client.
inherited
-
closeCurrentEventStream(
) → Future< void> -
Cancel the current HTTP event stream subscription.
inherited
-
connectEventListener(
ConnectionStreamBuilder sseStreamBuilder) → Future< void> -
Connects the HTTP event listener using the provided stream builder.
inherited
-
dispose(
) → Future< void> -
Dispose controller.
Call
clear()and close stream controller. Non of the actions can be done after disposing.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDataEvent(
Map< String, dynamic> event) → FutureOr<void> -
Handles incoming data events.
override
-
onDoneEvent(
) → void -
Handles stream completion event.
override
-
onErrorEvent(
Object error, StackTrace stacktrace, [Map< String, dynamic> ? sourceEvent]) → FutureOr<void> -
Handles incoming error events.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited