append
Yields all values of the source, then one extra value at the end.
Iterable<A> append<A>(A a, Iterable<A> iterable)
FxAsyncIterable<A> appendAsync<A>(FutureOr<A> a, FxAsyncIterable<A> iterable)
Fx<T> Fx.append(T a) // chain
FxAsync<T> FxAsync.append(FutureOr<T> a)
Lecture
append is the simplest way to tack a single trailing value
onto a lazy sequence without materializing anything: it just yields
through the whole source and then yields a once the source
is exhausted. Because the source is only consumed when pulled, this
works fine even when the source is expensive to compute — the extra
value is truly the last thing produced.
On the async side, a itself may be a Future —
appendAsync awaits it only once the upstream is done, so a
slow "closing" value doesn't hold anything up early.
Demo 1 · Basics
Demo 2 · Async, with a future value
Try it yourself
Exercise: append 'cool' to the end of the steps.