FxDart 入门
一门重实践的课程。每一课都是一段简短讲解,配有实时演示和 playground —— 代码由真正的 Dart 编译器编译,并在你的浏览器中运行。 你可以按顺序学完各个章节,也可以直接跳到下面的任意函数。
初次接触? 从
选哪一面 开始 —
手头的数据、有上限的 I/O、随时间到来的事件,或作为值的失败。
然后是 pull 入门:
fx →
map →
filter →
take →
toList,
再进入
concurrent。
任务:
防抖搜索
·
有上限的并发 fetch。
📒 看看实际效果:Daily Ledger —— 用 FxDart 构建的完整应用 →
章节 1 · 快速上手
管道模型:惰性构建,由终结操作符触发执行。
章节 2 · 生成序列
可以作为管道起点的数据源。
章节 3 · 转换
惰性地重塑每个元素。
章节 4 · 过滤 & 去重
只保留你需要的部分。
- where
- whereNot
- nonNulls
- distinct
- distinctBy
- uniqStrict
- uniqAdjacent
- takeUniqBy
- difference
- differenceBy
- intersection
- intersectionBy
- compress
章节 5 · 切片
滑动窗口、前缀、后缀与分块。
- take
- takeLast
- takeWhile
- takeWhileRight
- takeUntilInclusive
- skip
- dropRight
- skipWhile
- dropWhileRight
- dropUntil
- slice
- chunk
- windowed
- pairwise
- split
章节 6 · 组合
多个序列进,一个序列出。
- append
- prepend
- concat
- zip
- zip3
- zipWith
- indexed
- …WithIndex (map, filter, fold)
- transpose
- reverse
- fork
- tee
- tee3
- ifEmpty
章节 7 · 聚合
拉动整条管道并产出结果的终结操作符。
- reduce
- fold
- foldRight
- reduceLazy
- sum
- sumBy
- average
- averageBy
- min
- max
- maxBy
- minBy
- count
- join
- groupBy
- groupedBy
- indexBy
- countBy
- foldBy
- foldByOrSkip
- countWhere
- sort
- sortBy
- sortByDesc
- partition
章节 8 · 取值 & 判定
取出单个值,以及对元素做判定。
- firstOrNull
- lastOrNull
- elementAtOrNull
- firstWhereOrNull
- indexWhere
- contains
- isEmpty
- every
- any
- predicates (isNull, isString, …)
章节 9 · 对象(Map)函数
FxTS 的对象工具函数,移植到 Dart 的 Map 上。
- fromEntries
- omit
- pick
- omitBy
- pickBy
- prop
- props
- mapValues
- evolve
- compactObject
- resolveProps
- isMatch
- matches
章节 10 · 函数工具
组合子与辅助函数。
- identity
- always
- tap
- apply
- juxt
- fxPipe
- memoize
- negate
- not
- predicate combinators
- when
- unless
- throwError
- throwIf
- cases
- add
- gt · gte · lt · lte
- delay & sleep
- unicodeToList
- curried & uncurried
章节 11 · 异步 & 并发
FxAsyncIterable 模型 —— FxDart 的看家本领。
- toAsync
- async variants (mapAsync, …)
- Stream bridges
- concurrent
- mapConcurrent
- concurrentPool
- retry
- timeout
- using
- concurrent or parallel
- parallel
章节 12 · 实用工具
限流与随机。
章节 13 · Typed errors
The Kotlin Arrow approach, ported: either, Raise, bind, ensure, error accumulation with Nel, and pipeline-fused validation. Straight-line code, typed failures, no wrapper tower.
- typed errors — full guide
- Either
- Either combinators
- either & Raise scope
- nullable
- NonEmptyList (Nel)
- accumulation (zipOrAccumulate, …)
- Either × pipelines
章节 14 · Event streams (push)
FxDart's push side — Rx-style operators over plain Dart Streams, bridging into the pull pipelines.
- fxEvents
- constructors
- peek · whenComplete
- sampleOn
- combineLatest
- withLatestFrom
- switchMap
- mergeMap
- switchLatest
- mergeScan
- race
- waitAll
- combine
- stopOn
- chunkOn
- windowOn
- groupsBy
- spaceBy
- debounceOn
- retryOn
- onErrorResume
- attempt
- mapEither
- separated
- share
- shareReplay
- LiveValue
- FxSubscriptions
- materialize
章节 15 · Jobs
Cross-surface programs — the reason to import one package rather than three.