Segment class abstract
Base class for building event topic paths with chaining support.
Segments allow you to construct event topics by chaining method calls, making it easy to build complex event paths programmatically.
Example:
class UserSegment extends Segment {
UserSegment() : super('user');
}
final userEvents = UserSegment();
userEvents.$('profile').$('update').emit<String>('John Doe');
Constructors
- Segment.new(String topic)
-
Creates a new segment with the given base
topic
.
Properties
Methods
-
$(
String data) → Segment - Appends a new segment to the current topic path.
-
emit<
T> ([T? data, bool retain = false]) → void - Emits an event on the current topic path.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on<
T> (EventCallback< T> callback) → EventListener<T> - Registers a listener for events on the current topic path.
-
toString(
) → String -
A string representation of this object.
override
-
waitForData<
T> () → Future< T?> - Waits for a single event and returns the event data.
-
waitForEvent<
T> (EventCallback< T> callback) → Future<void> - Waits for a single event on the current topic path.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited