{"id":17238374,"url":"https://github.com/hoc081098/rxdart_ext","last_synced_at":"2025-03-17T16:10:39.649Z","repository":{"id":38406080,"uuid":"308276515","full_name":"hoc081098/rxdart_ext","owner":"hoc081098","description":"Some extension methods and classes built on top of RxDart. Companion with RxDart","archived":false,"fork":false,"pushed_at":"2025-02-27T00:54:55.000Z","size":503,"stargazers_count":26,"open_issues_count":13,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T13:11:46.972Z","etag":null,"topics":["flutter-bloc-pattern-rxdart","flutter-bloc-rxdart","flutter-rx","flutter-rxdart","rxdart","rxdart-bloc","rxdart-debug-operator","rxdart-ext","rxdart-extension","rxdart-extensions","rxdart-flutter","rxdart-helper","rxdart-redux"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/rxdart_ext","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoc081098.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["hoc081098"],"custom":["https://www.buymeacoffee.com/hoc081098"]}},"created_at":"2020-10-29T09:21:25.000Z","updated_at":"2024-11-17T10:08:33.000Z","dependencies_parsed_at":"2024-05-03T12:59:33.081Z","dependency_job_id":"03998d4f-db5f-4851-8475-585fc9cbad84","html_url":"https://github.com/hoc081098/rxdart_ext","commit_stats":{"total_commits":290,"total_committers":5,"mean_commits":58.0,"dds":0.04482758620689653,"last_synced_commit":"d1b1ca8ea5ba1f80bb0aba89885333a6bd96dd0e"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Frxdart_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Frxdart_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Frxdart_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Frxdart_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoc081098","download_url":"https://codeload.github.com/hoc081098/rxdart_ext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066180,"owners_count":20392406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flutter-bloc-pattern-rxdart","flutter-bloc-rxdart","flutter-rx","flutter-rxdart","rxdart","rxdart-bloc","rxdart-debug-operator","rxdart-ext","rxdart-extension","rxdart-extensions","rxdart-flutter","rxdart-helper","rxdart-redux"],"created_at":"2024-10-15T05:45:27.323Z","updated_at":"2025-03-17T16:10:39.630Z","avatar_url":"https://github.com/hoc081098.png","language":"Dart","funding_links":["https://github.com/sponsors/hoc081098","https://www.buymeacoffee.com/hoc081098"],"categories":[],"sub_categories":[],"readme":"# rxdart_ext\n\n## Author: [Petrus Nguyễn Thái Học](https://github.com/hoc081098)\n\n[![codecov](https://codecov.io/gh/hoc081098/rxdart_ext/branch/master/graph/badge.svg?token=OYMVzeUB1m)](https://codecov.io/gh/hoc081098/rxdart_ext)\n[![Dart CI](https://github.com/hoc081098/rxdart_ext/actions/workflows/dart.yml/badge.svg)](https://github.com/hoc081098/rxdart_ext/actions/workflows/dart.yml)\n[![Pub Version (including pre-releases)](https://img.shields.io/pub/v/rxdart_ext?include_prereleases)](https://pub.dev/packages/rxdart_ext)\n[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fhoc081098%2Frxdart_ext\u0026count_bg=%2379C83D\u0026title_bg=%23555555\u0026icon=\u0026icon_color=%23E7E7E7\u0026title=hits\u0026edge_flat=false)](https://hits.seeyoufarm.com)\n[![GitHub](https://img.shields.io/github/license/hoc081098/rxdart_ext?color=4EB1BA)](https://opensource.org/licenses/MIT)\n[![Style](https://img.shields.io/badge/style-lints-40c4ff.svg)](https://pub.dev/packages/lints)\n\nSome extension methods and classes built on top of [`RxDart`](https://pub.dev/packages/rxdart) - [`RxDart`](https://pub.dev/packages/rxdart) extension.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/hoc081098/rxdart_ext/blob/master/screenshots/logo.png?raw=true\" height=\"200\" alt=\"RxDart\" /\u003e\n\u003c/p\u003e\n\nLiked some of my work? Buy me a coffee (or more likely a beer)\n\n\u003ca href=\"https://www.buymeacoffee.com/hoc081098\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-blue.png\" alt=\"Buy Me A Coffee\" height=64\u003e\u003c/a\u003e\n\n## RxDart and Dart SDK compatibility\n\n| **rxdart_ext**  | **rxdart** |   **Dart SDK**    |\n|:---------------:|:----------:|:-----------------:|\n|     `0.1.2`     | `^0.27.2`  | `\u003e=2.12.0 \u003c4.0.0` |\n| `0.1.3 → 0.2.0` | `^0.27.3`  | `\u003e=2.12.0 \u003c4.0.0` |\n| `0.2.1 → 0.2.2` | `^0.27.4`  | `\u003e=2.12.0 \u003c4.0.0` |\n| `0.2.3 → 0.2.9` | `^0.27.5`  | `\u003e=2.12.0 \u003c4.0.0` |\n|    `^0.3.0`     | `^0.28.0`  | `\u003e=2.12.0 \u003c4.0.0` |\n|    `^0.4.0`     | `^0.28.0`  |     `^3.0.0`      |\n\n**The latest version of `rxdart_ext` always works fine with the latest version of `rxdart`.**\n\n## API - [Documentation](https://pub.dev/documentation/rxdart_ext/latest/)\n\n### 1. [Single](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single-class.html)\n\nA Stream which emits single event, either data or error, and then close with a done-event.\n\n```text\nSuccess case: ------------(*)|------\n                         data done\n\nFailure case: ------------(x)|------\n                        error done\n```\n\n\u003e NOTE: Single extends Stream, so all operators and transformers for Stream are available for Single as well.\n\n`Single` is suitable for one-shot operations (likes `Future` but **lazy** - executes when listening), eg. making API request, reading local storage, ...\n\n```dart\nimport 'package:http/http.dart' as http;\n\nSingle\u003cUser\u003e fetchUser(String id) {\n  return Single.fromCallable(() =\u003e http.get(Uri.parse('$baseUrl/users/$id')))\n      .flatMapSingle((res) =\u003e res.statusCode == HttpStatus.ok\n          ? Single.value(res.body)\n          : Single.error(Exception('Cannot fetch user with id=$id')))\n      .map((body) =\u003e User.fromJson(jsonEncode(body)));\n}\n```\n\n- Create Single\n\n  - Factory constructors.\n\n    - [Single.unsafeFromStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.unsafeFromStream.html)\n    - [Single.value](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.value.html)\n    - [Single.error](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.error.html)\n    - [Single.fromFuture](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.fromFuture.html)\n    - [Single.fromCallable](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.fromCallable.html)\n    - [Single.timer](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.timer.html)\n    - [Single.defer](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.defer.html)\n    - [Single.retry](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/Single/Single.retry.html)\n\n  - Static methods provided by [RxSingles]() class\n    - [RxSingles.zip2](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/RxSingles/zip2.html)\n    - [RxSingles.forkJoin2](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/RxSingles/forkJoin2.html)\n      ..[RxSingles.forkJoin9](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/RxSingles/forkJoin9.html)\n      and [RxSingles.forkJoinList](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/RxSingles/forkJoinList.html)\n    - [RxSingles.using](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/RxSingles/using.html)\n  - Convert others to Single via extensions.\n    - [Stream.singleOrError](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/SingleOrErrorStreamExtension/singleOrError.html)\n    - [Future.asSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsSingleFutureExtension/asSingle.html)\n    - [`(FutureOr\u003cT\u003e Function())`.asSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsSingleFunctionExtension/asSingle.html)\n\n- Operators for Single (returns a Single instead of Stream)\n  - [asNullable](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsNullableSingleExtension/asNullable.html)\n  - [flatMapSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/FlatMapSingleExtension/flatMapSingle.html)\n  - [flatMapEitherSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/FlatMapEitherSingleExtension/flatMapEitherSingle.html)\n  - [asyncExpandSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsyncExpandSingleExtension/asyncExpandSingle.html)\n  - [switchMapSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/SwitchMapSingleExtension/switchMapSingle.html)\n  - [exhaustMapSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ExhaustMapSingleExtension/exhaustMapSingle.html)\n  - [debug](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DebugSingleExtension/debug.html)\n  - [delay](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DelaySingleExtension/delay.html)\n  - [doOnCancel](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DoSingleExtensions/doOnCancel.html)\n  - [doOnData](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DoSingleExtensions/doOnData.html)\n  - [doOnError](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DoSingleExtensions/doOnError.html)\n  - [doOnListen](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DoSingleExtensions/doOnListen.html)\n  - [onErrorReturn](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/OnErrorResumeSingleExtensions/onErrorReturn.html)\n  - [onErrorReturnWith](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/OnErrorResumeSingleExtensions/onErrorReturnWith.html)\n  - [onErrorResumeSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/OnErrorResumeSingleExtensions/onErrorResumeSingle.html)\n  - [onErrorResumeNextSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/OnErrorResumeSingleExtensions/onErrorResumeNextSingle.html)\n  - [mapTo](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/MapToSingleExtension/mapTo.html)\n  - [toEitherSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ToEitherSingleExtension/toEitherSingle.html)\n  - [asVoid](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsVoidSingleExtension/asVoid.html)\n\n### 2. Operators for Stream\n\n- [asNullable](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsNullableStreamExtension/asNullable.html)\n- [debug](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DebugStreamExtension/debug.html), [collect](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/CollectStreamExtension/collect.html)\n- [distinctUniqueBy](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DistinctUniqueByStreamExtension/distinctUniqueBy.html)\n- [distinctBy](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DistinctByExtension/distinctBy.html)\n- [doOn](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DoOnStreamExtensions/doOn.html)\n- [doneOnError](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DoneOnErrorStreamExtension/doneOnError.html)\n- [flatMapBatches](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/FlatMapBatchesStreamExtension/flatMapBatches.html)\n- [flatMapBatchesSingle](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/FlatMapBatchesStreamExtension/flatMapBatchesSingle.html)\n- [ignoreErrors](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/IgnoreErrorsStreamExtension/ignoreErrors.html)\n- `mapNotNull` (moved to `rxdart 0.27.4` as standard operator: [mapNotNull](https://pub.dev/documentation/rxdart/latest/rx/MapNotNullExtension/mapNotNull.html))\n- [toSingleSubscription](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ToSingleSubscriptionStreamExtension/toSingleSubscriptionStream.html)\n- [asVoid](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/AsVoidStreamExtension/asVoid.html)\n- `whereNotNull` (moved to `rxdart 0.27.4` as standard operator: [whereNotNull](https://pub.dev/documentation/rxdart/latest/rx/WhereNotNullExtension/whereNotNull.html))\n\n### 3. [StateStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/StateStream-class.html)\n\nA Stream that provides synchronous access to the last emitted item,\nand two consecutive values are not equal.\nThe equality between previous data event and current data event is determined by [StateStream.equals](\u003c(https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/StateStream/equals.html)\u003e).\nThis Stream always has no error.\n\n- Broadcast\n  - [StateSubject](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/StateSubject-class.html)\n  - [StateConnectableStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/StateConnectableStream-class.html)\n    - [publishState](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/StateConnectableExtensions/publishState.html)\n    - [shareState](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/StateConnectableExtensions/shareState.html)\n- Single-subscription\n  - [toStateStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ToStateStreamExtension/toStateStream.html)\n\n#### Example\n\nUseful for `Flutter BLoC pattern` - `StreamBuilder`, expose broadcast state stream to UI, can synchronous access to the last emitted item, and distinct until changed\n\n- [x] `Distinct`: distinct until changed.\n- [x] `Value`: can synchronous access to the last emitted item.\n- [x] `NotReplay`: not replay the latest value.\n- [x] `Connectable`: broadcast stream - can be listened to multiple time.\n\n```\n                                Stream (dart:core)\n                                   ^\n                                   |\n                                   |\n            |--------------------------------------------|\n            |                                            |\n            |                                            |\n        ValueStream (rxdart)                             |\n            ^                                            |\n            |                                            |\n            |                                            |\n    NotReplayValueStream (rxdart_ext)                    |\n            ^                                    ConnectableStream (rxdart)\n            |                                            ^\n            |                                            |\n       StateStream (rxdart_ext)                          |\n            ^                                            |\n            |                                            |\n            |------------                     -----------|\n                        |                     |\n                        |                     |\n                     StateConnectableStream (rxdart_ext)\n```\n\n```dart\nclass UiState { ... }\n\nfinal Stream\u003cUiState\u003e state$ = ...;\n\nfinal StateConnectableStream\u003cUiState\u003e state$ = state$.publishState(UiState.initial());\nfinal connection = state$.connect();\n\nStreamBuilder\u003cUiState\u003e(\n  initialData: state$.value,\n  stream: state$,\n  builder: (context, snapshot) {\n    final UiState state = snapshot.requireData;\n\n    return ...;\n  },\n);\n```\n\nSee also [flutter_bloc_pattern/RxStreamBuilder](https://pub.dev/documentation/flutter_bloc_pattern/latest/flutter_bloc_pattern/RxStreamBuilder-class.html),\nit can be used with `StateStream` perfectly and more easily (don't require `initialData` and don't need to call `snapshot.requireData`).\n\n```dart\nfinal StateStream\u003cUiState\u003e state$;\n\nRxStreamBuilder\u003cUiState\u003e(\n  stream: state$,\n  builder: (context, UiState state) {\n    // use state directly\n    return ...;\n  }\n);\n```\n\n### 4. [NotReplayValueStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/NotReplayValueStream-class.html)\n\nA Stream that provides synchronous access to the last emitted item, but not replay the latest value.\n\n- Broadcast\n  - [ValueSubject](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueSubject-class.html)\n  - [NotReplayValueConnectableStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/NotReplayValueConnectableStream-class.html)\n    - [publishValueNotReplay](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueConnectableNotReplayStreamExtensions/publishValueNotReplay.html)\n    - [shareValueNotReplay](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueConnectableNotReplayStreamExtensions/shareValueNotReplay.html)\n- Single-subscription\n  - [ValueStreamController](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueStreamController-class.html)\n  - [toNotReplayValueStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ToNotReplayValueStreamExtension/toNotReplayValueStream.html)\n\n### 5. Utils\n\n#### DisposableMixin\n\nA mixin that makes it easy to dispose streams without having to store and close a `StreamSubscription` variable.\n\nTypical usage is as follows:\n\n```dart\nclass DisposableExample with DisposableMixin {\n  DisposableExample({\n    required Stream\u003cDateTime\u003e dateTimeStream,\n  }) {\n    dateTimeStream.takeUntil(dispose$).listen(\n          (value) =\u003e print('Disposable example: $value'),\n        );\n  }\n}\n```\n\n## License\n\n    MIT License\n\n    Copyright (c) 2020-2022 Petrus Nguyễn Thái Học\n\n![Tim Cook dancing to the sound of a permissive license.](http://i.imgur.com/mONiWzj.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoc081098%2Frxdart_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoc081098%2Frxdart_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoc081098%2Frxdart_ext/lists"}