Skip to content

Commit

Permalink
refactor(realtime_client): Add docs on .subscribe() and give callba…
Browse files Browse the repository at this point in the history
…ck parameters names (#507)

* refactor: add comments and properly name parameters

* Update packages/realtime_client/lib/src/realtime_channel.dart

Co-authored-by: Tyler <18113850+dshukertjr@users.noreply.github.com>

---------

Co-authored-by: Vinzent <vinzent03@proton.me>
  • Loading branch information
dshukertjr and Vinzent03 committed Jun 10, 2023
1 parent a4cb4c5 commit 7f9b310
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/realtime_client/lib/src/realtime_channel.dart
Expand Up @@ -180,8 +180,16 @@ class RealtimeChannel {
}
}

void subscribe(
[void Function(String, [Object?])? callback, Duration? timeout]) {
/// Subscribes to receive real-time changes
///
/// Pass a [callback] to react to different status changes. Values of `status`
/// can be `SUBSCRIBED`, `CHANNEL_ERROR`, `CLOSED`, or `TIMED_OUT`.
///
/// [timeout] parameter can be used to override the default timeout set on `RealtimeClient`.
void subscribe([
void Function(String status, [Object? error])? callback,
Duration? timeout,
]) {
if (joinedOnce == true) {
throw "tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";
} else {
Expand Down

0 comments on commit 7f9b310

Please sign in to comment.