EventFluxBase class abstract
Abstract base class for EventFlux connection management.
This class defines the core interface for managing connections in an EventFlux implementation. It declares methods for connecting, disconnecting, and reconnecting to an event stream.
Implementing classes are expected to provide concrete implementations for these methods, adhering to the behavior and specifications outlined here.
Methods:
-
connect
: Establishes a connection to an event stream based on the given parameters. This method must be implemented by subclasses to initiate a connection using the specified connection type, URL, headers, and optional body. It returns anEventFluxResponse
inonSuccessCallback
if the connection is establised and when it receives the data.- Parameters:
type
: TheEventFluxConnectionType
(GET or POST) indicating the type of HTTP connection.url
: The URL of the event stream to connect to.onSuccessCallback
: Required callback function that is called upon a successfulheader
: Optional HTTP headers for the request. Defaults to accepting 'text/event-stream'.body
: Optional body for POST requests.onConnectionClose
: Optional callback function that is called when the connection is closed.autoReconnect
: Optional flag to enable automatic reconnection. Defaults to false.reconnectConfig
: Optional configuration for reconnection attempts. IfautoReconnect
is true, this parameter is required.
tag
: Optional tag to identify the connection.
- Parameters:
-
disconnect
: Disconnects from the current event stream. This method must be implemented by subclasses to properly close any open connections and perform necessary cleanup. It returns anEventFluxStatus
indicating the result of the disconnection attempt.
Example Implementation:
class MyEventFlux extends EventFluxBase {
@override
EventFluxResponse connect(...) {
// implementation
}
@override
EventFluxStatus disconnect() {
// implementation
}
This abstract class is central to ensuring a consistent interface for EventFlux connection management across different implementations.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
EventFluxConnectionType type, String url, {required dynamic onSuccessCallback(EventFluxResponse?), Map< String, String> header = const {'Accept' : 'text/event-stream'}, dynamic onConnectionClose()?, bool autoReconnect = false, ReconnectConfig? reconnectConfig, dynamic onError(EventFluxException)?, Map<String, dynamic> ? body, String? tag, bool logReceivedData = false}) → void -
disconnect(
) → Future< EventFluxStatus> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited