Skip to content

Commit

Permalink
Add unsubscribe(), pause(), and resume() methods to RawStreamBeacon
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyus committed Feb 20, 2024
1 parent 1070043 commit 7129ce9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/state_beacon_core/lib/src/beacons/stream_raw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ class RawStreamBeacon<T> extends ReadableBeacon<T> with _AutoSleep<T, T> {
/// passed to the internal stream subscription
final bool cancelOnError;

/// unsubscribes from the internal stream
void unsubscribe() {
unawaited(_sub?.cancel());
_sub = null;
}

/// Pauses the internal stream subscription
void pause([Future<void>? resumeSignal]) {
_sub?.pause(resumeSignal);
}

/// Resumes the internal stream subscription
/// if it was paused.
void resume() {
_sub?.resume();
}

/// Starts listening to the internal stream
/// if `manualStart` was set to true.
///
Expand Down

0 comments on commit 7129ce9

Please sign in to comment.