rxdart_ext 0.1.1-dev.1 copy "rxdart_ext: ^0.1.1-dev.1" to clipboard
rxdart_ext: ^0.1.1-dev.1 copied to clipboard

outdated

Some extension methods and classes built on top of RxDart - RxDart extension.

rxdart_ext #

Author: Petrus Nguyễn Thái Học #

codecov Dart CI Pub Version (including pre-releases) Hits GitHub Style

Some extension methods and classes built on top of RxDart - RxDart extension.

API #

Single #

A Stream which emits single event, either data or error, and then close with a done-event.

Success case: ------------(*)|------
                         data done

Failure case: ------------(x)|------
                        error done

NOTE: Single extends Stream, so all operators and transformers for Stream are available for Single as well.

Single is suitable for one-shot operations (likes Future but lazy - executes when listening), eg. making API request, reading local storage, ...

import 'package:http/http.dart' as http;

Single<User> fetchUser(String id) {
  return Single.fromCallable(() => http.get(Uri.parse('$baseUrl/users/$id')))
      .flatMapSingle((res) => res.statusCode == HttpStatus.ok
          ? Single.value(res.body)
          : Single.error(Exception('Cannot fetch user with id=$id')))
      .map((body) => User.fromJson(jsonEncode(body)));
}

Operators for Stream #

NotReplayValueStream #

A Stream that provides synchronous access to the last emitted item, but not replay the latest value.

RxDart compatibility #

rxdart rxdart_ext
^0.26.0 ^0.0.1
^0.27.0 ^0.1.0
10
likes
0
pub points
88%
popularity

Publisher

unverified uploader

Some extension methods and classes built on top of RxDart - RxDart extension.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta, path, rxdart, stack_trace

More

Packages that depend on rxdart_ext