Skip to content

Commit

Permalink
docs: update docs for Single.fromFuture
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Jun 16, 2024
1 parent 57931d3 commit 3815b05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/src/single/as_single.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import 'single.dart';

/// Provides [asSingle] extension for [Future].
extension AsSingleFutureExtension<T> on Future<T> {
/// Converts this [Future] into a [Single].
/// Converts this [Future] into a [Single]. It is a shorthand for [Single.fromFuture].
///
/// See [Single.fromFuture].
/// See also [Single.fromCallable] and [Single.defer]. These methods are useful
/// or creating [Single]s that don't instantiate [Future]s until they are listened to.
Single<T> asSingle() => Single.fromFuture(this);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/src/single/single.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class Single<T> extends StreamView<T> {
///
/// NOTE: x is error event
/// ```
///
/// See also [Single.fromCallable] and [Single.defer]. These methods are useful
/// for creating [Single]s that don't instantiate [Future]s until they are listened to.
factory Single.fromFuture(Future<T> future) =>
Single.safe(Stream.fromFuture(future));

Expand Down

0 comments on commit 3815b05

Please sign in to comment.