EXPERIMENTAL This is an experimental package.
Use @most/core
with a fluent API. @most/fluent
wraps a @most/core
Stream in a FluentStream type that provides thru
and apply
methods for dot-chaining.
npm i @most/fluent --save
yarn add @most/fluent
import { change } from `@most/dom-event`
import { map, filter } from `@most/core`
import { fluently } from `@most/fluent`
const changes = change(inputElement)
// Wrap a @most/core stream of change events and fluently
// map change events to their associated input value, and
// retain only non-empty values
const changesFluent = fluently(changes)
.thru(map(e => e.target.value))
.thru(filter(value => value.length > 0))
A FluentStream is a Stream with two additional methods that enable fluent (dot-chaining) usage.
type FluentStream<A> = Stream<A> & {
thru <B> (f: (Stream<A>) => Stream<B>): FluentStream<B>
apply <B> (f: (Stream<A>) => B): B
}
Wrap a @most/core
Stream in a FluentStream.
Apply functions fluently to a Stream, wrapping the result in a FluentStream. Use thru
when you want to continue dot-chaining other Stream operations.
Apply functions fluently to a Stream, without re-wrapping the result. Use apply
to return something other than a Stream.