搜索插件、代码仓与 APP 分类

GitHub 代码仓dart-archive/stream_transform

stream_transform

用于创建 StreamTransfomer 实例以操作流的 Dart 工具方法

stream_transform 项目封面
星标
122
复刻
20
最近推送(UTC)
2024年12月17日
项目状态
已归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

[!IMPORTANT]
This repo has moved to https://github.com/dart-lang/tools/tree/main/pkgs/stream_transform

Dart CI Pub package package publisher

Extension methods on Stream adding common transform operators.

Operators

asyncMapBuffer, asyncMapSample, concurrentAsyncMap

Alternatives to asyncMap. asyncMapBuffer prevents the callback from overlapping execution and collects events while it is executing. asyncMapSample prevents overlapping execution and discards events while it is executing. concurrentAsyncMap allows overlap and removes ordering guarantees for higher throughput.

Like asyncMap but events are buffered in a List until previous events have been processed rather than being called for each element individually.

asyncWhere

Like where but allows an asynchronous predicate.

audit

Waits for a period of time after receiving a value and then only emits the most recent value.

buffer

Collects values from a source stream until a trigger stream fires and the collected values are emitted.

combineLatest, combineLatestAll

Combine the most recent event from multiple streams through a callback or into a list.

debounce, debounceBuffer

Prevents a source stream from emitting too frequently by dropping or collecting values that occur within a given duration.

followedBy

Appends the values of a stream after another stream finishes.

merge, mergeAll, concurrentAsyncExpand

Interleaves events from multiple streams into a single stream.

scan

Scan is like fold, but instead of producing a single value it yields each intermediate accumulation.

startWith, startWithMany, startWithStream

Prepend a value, an iterable, or a stream to the beginning of another stream.

switchMap, switchLatest

Flatten a Stream of Streams into a Stream which forwards values from the most recent Stream

takeUntil

Let values through until a Future fires.

tap

Taps into a single-subscriber stream to react to values as they pass, without being a real subscriber.

throttle

Blocks events for a duration after an event is successfully emitted.

whereType

Like Iterable.whereType for a stream.

Comparison to Rx Operators

The semantics and naming in this package have some overlap, and some conflict, with the ReactiveX suite of libraries. Some of the conflict is intentional - Dart Stream predates Observable and coherence with the Dart ecosystem semantics and naming is a strictly higher priority than consistency with ReactiveX.

Rx Operator Category variation stream_transform
sample sample/throttleLast(Duration) sample(Stream.periodic(Duration), longPoll: false)
​ throttleFirst(Duration) throttle
​ sample(Observable) sample(trigger, longPoll: false)
debounce debounce/throttleWithTimeout(Duration) debounce
​ debounce(Observable) No equivalent
buffer buffer(boundary), bufferWithTime,bufferWithCount No equivalent
​ buffer(boundaryClosingSelector) buffer(trigger, longPoll: false)
RxJs extensions audit(callback) No equivalent
​ auditTime(Duration) audit
​ exhaustMap No equivalent
​ throttleTime(trailing: true) throttle(trailing: true)
​ throttleTime(leading: false, trailing: true) No equivalent
No equivalent? asyncMapBuffer
​ asyncMapSample
​ buffer
​ sample
​ debounceBuffer
​ debounce(leading: true, trailing: false)
​ debounce(leading: true, trailing: true)

Getting a StreamTransformer instance

It may be useful to pass an instance of StreamTransformer so that it can be used with stream.transform calls rather than reference the specific operator in place. Any operator on Stream that returns a Stream can be modeled as a StreamTransformer using the fromBind constructor.

final debounce = StreamTransformer.fromBind(
    (s) => s.debounce(const Duration(milliseconds: 100)));
Dart Archive GitHub avatar
GitHub 作者

Dart Archive ↗

Legacy projects kept around for posterity – See github.com/dart-lang for current work

语言DartHTML

使用的依赖

依赖清单 4 项

  • async开发依赖^2.5.0
  • dart_flutter_team_lints开发依赖^2.0.0
  • fake_async开发依赖^1.3.0
  • test开发依赖^1.16.0

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗