From 824c8db09aa0c7a6c5ed0a1eece1ccc09f57dedd Mon Sep 17 00:00:00 2001 From: "Rohit R. Abbadi" Date: Fri, 24 Jul 2020 13:37:49 +0530 Subject: [PATCH] README update for subscription. Skadoosh...! --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index e50efb6a9..e9c05109d 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,23 @@ Detaching from channel await channel.detach(); ``` +Subscribing to channel messages + +```dart +Stream messageStream = channel.subscribe(); +StreamSubscription channelMessageSubscription = messageStream.listen((ably.Message message){ + print("New message arrived ${message.data}"); +}); +``` + +_use `channel.subscribe(name: "shifu")` or `channel.subscribe(names: ["shifu", "oogway"])` to listen to specific named messages_ + +UnSubscribing from channel messages + +```dart +await channelMessageSubscription.cancel(); +``` + ## Caveats #### RTE6a compliance