Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime message subscription #21

Merged
merged 20 commits into from
Aug 12, 2020
Merged

Conversation

tiholic
Copy link
Contributor

@tiholic tiholic commented Jul 24, 2020

Listening to messages on a Realtime Channel

This implementation follows dart idiomatic approach

Subscribing

Stream<ably.Message> messageStream = channel.subscribe();
StreamSubscription<ably.Message> channelMessageSubscription = messageStream.listen((ably.Message message){
  print("New message arrived ${message.data}");
});

Unsubscribing

await channelMessageSubscription.cancel();

@tiholic tiholic force-pushed the feature/realtime-message-subscription branch from 824c8db to 1dfaab3 Compare July 25, 2020 09:14
Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been offline for a few hours this afternoon so apologies for the late review submit. I wrote most of the comments in the AM but only just submitting the review as a whole now.

DeveloperNotes.md Show resolved Hide resolved
DeveloperNotes.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@tiholic tiholic force-pushed the feature/realtime-message-subscription branch from da53d26 to 7b4db0b Compare July 30, 2020 06:41
@tiholic tiholic force-pushed the feature/channel-state-events branch from bb9f4f5 to f7bf23f Compare August 3, 2020 10:34
@tiholic tiholic force-pushed the feature/realtime-message-subscription branch from f40547b to 1624991 Compare August 3, 2020 10:35
@tiholic tiholic requested a review from zoechi August 3, 2020 11:27
Copy link
Contributor

@zoechi zoechi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions

README.md Show resolved Hide resolved
example/lib/main.dart Outdated Show resolved Hide resolved
lib/src/impl/realtime/channels.dart Outdated Show resolved Hide resolved
lib/src/spec/message.dart Show resolved Hide resolved
lib/src/spec/message.dart Outdated Show resolved Hide resolved
@tiholic tiholic force-pushed the feature/realtime-message-subscription branch from 1624991 to eb93cb5 Compare August 4, 2020 20:07
tiholic added a commit that referenced this pull request Aug 4, 2020
tiholic added a commit that referenced this pull request Aug 4, 2020
@tiholic tiholic mentioned this pull request Aug 11, 2020
Base automatically changed from feature/channel-state-events to main August 12, 2020 15:08
tiholic added 11 commits August 12, 2020 20:39
1. Message class cleaned up
2. only `subscribe`, forget unsubscribe - following idiomatic cancellation
3. message decoder for messages arriving from platform
Timestamp is not supported by platform channel default codec, so using long
1. stream.takeWhile will cancel on first failure
2. rename `event` and `events` to `name` and `names` to match IDL
@tiholic tiholic force-pushed the feature/realtime-message-subscription branch from 515167b to d582121 Compare August 12, 2020 15:09
@tiholic tiholic merged commit 2adf5d3 into main Aug 12, 2020
tiholic added a commit that referenced this pull request Aug 12, 2020
@tiholic tiholic deleted the feature/realtime-message-subscription branch August 12, 2020 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants