PubSub class
PubSub manages its subscriptions. You can subscribe and unsubscribe to topics, send them messages. Example:
PubSub pubsub = PubSub();
Subscription? sub = pubsub?.subscribe('topic');
sub?.stream?.listen((message) {
print(message);
});
pubsub.publish('topic', 'hello');
// console log - hello
pubsub.unsubscribe(sub);
Properties
Methods
-
getTopics(
) → Set< String?> ? - Return set of pubsub topics
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
publish(
String? topic, dynamic message) → void - Sends messages to all subscribers of this topic.
-
publishAll(
dynamic message) → void - Sends messages to all subscribers of all topics.
-
publishMany(
Set< String?> topics, dynamic message) → void - Sends messages to all subscribers of several topics.
-
subscribe(
String? topic) → Subscription? - Creates and stores a subscription to a topic. Return Subscription.
-
subscribeToMany(
Set< String?> ? topics) → Subscription? - Creates and stores a subscription to several topics. Return Subscription.
-
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribe(
Subscription? subscription) → Future< void> ? - Deletes a subscription to a topic.
-
unsubscribeAll(
String? topic) → Future< void> ? - Deletes all subscriptions to the specified topic.
-
unsubscribeMany(
List< Subscription?> ? subscribers) → Future<void> ? - Deletes multiple subscriptions at a time.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited