reverse
Returns the source in reverse order.
Iterable<A> fxReverse<A>(Iterable<A> iterable)
FxAsyncIterable<A> fxReverseAsync<A>(FxAsyncIterable<A> iterable)
Fx<T> Fx.reverse() // chain
FxAsync<T> FxAsync.reverse()
Lecture
reverse yields a source's elements last-to-first. Like
takeRight and dropRight, there's no way to know
what "last" means without first seeing everything, so reverse
materializes the whole source into a list before it
yields a single value. It's an operator for finite, bufferable sources —
it will never terminate on an infinite one.
fxReverseAsync follows the same rule: it awaits every element
of the upstream first, then replays them back to front. If you only need
the tail of a sequence rather than a true reversal, prefer
takeRight — it buffers only n elements instead
of the whole source.
Demo 1 · Basics
Demo 2 · Async (must buffer the whole source first)
Try it yourself
Exercise: reverse the history so the most recent visit comes first.