Topic class abstract

The event address: a type plus an optional path.

An address reads <type><separator><path...>, so with the default separator Topic.create<String>(paths: ['a', 'b']) is String.a.b.

Two topics are equal when their topic strings are equal — the type and the paths are what select a node. Call parameters (arguments) are payload and live on the EventDTO, not here.

The type token is derived from $T, so it is normalised to a token that is safe in a broker subject: < becomes (, > becomes ), and commas and whitespace become _. Without this a generic type such as List<int> would produce List<int>, and > is a wildcard in NATS.

Implementers

Constructors

Topic.fromParametr({Type? type, List<String>? paths, String separator = '.'})
The topic of an explicitly given type, for a type known only at runtime.
factory
Topic.fromString(String topic, {String separator = '.'})
factory
Topic.parse(String str, {String separator = '.'})
Parses an address built as <type><separator><path...>.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
paths → List<String>
The path tokens after the type. Empty when the address is the type alone.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
separator → String
The string that joins type and paths into topic.
no setter
topic → String
The routing key. This is the string the bus looks a node up by.
no setter
type → String
The event type — the first token of the address, usually T of the call.
no setter

Methods

copy({List<String>? paths, String? separator}) → Topic
A copy with paths and/or separator replaced. The type is kept.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

create<T>({List<String>? paths, String separator = '.'}) → Topic
The topic of the static type T with the given paths.