@swim/streamlet provides a stateful, streaming component model. Streamlets
are stateful application componets that continuously consume input state from
streaming inlets, and continuously produce output state on streaming outlets.
@swim/streamlet is written in TypeScript, but can be used from either
@swim/streamlet is included as part of the
@swim/streamlet defines a model for continuous stateful computations that
consume many streaming input states, and produce many streaming output states.
The streamlet model facilitates dynamic binding of streaming application
components to their inputs and outputs, and provides a precise, rate decoupled,
backpressure regulated, re-evaluation model for reconciling the state of
streamlet components after their transitively dependent input states change.
Streamlets are general purpose programming constructs; they are not restricted to modelling pure, data parallel functions. Unlinke Spark RDDs, or Flink Datasets, Streamlets can encapsulate arbitrary streaming business logic. And unlike Reactive Streams, which are purely demand driven, Streamlets model both supply and demand signals, enabling significantly optimized subgraph re-evaluation when sets of input states change concurrently.
The streamlet programming model introduces three key concepts: inlets, outlets, and streamlets.
Inlet– a consumer of state changes.
Outlet– a producer of state changes.
Streamlet– a stateful component with zero or more named input outlets, and zero or more named output inlets.
Outlet types provide specialized interfaces
for structured input and output states.
MapInlet– a consumer of keyed state changes, i.e. updates to a key-value map.
MapOutlet– a producer of keyed state changes, i.e. updates to a key-value map.
Outlets, being sources of state, define functional combinators, such as
reduce, that produce new, transformed outlets. The Streamlet
model enables ultra efficient recomputation of combinators. The
combinator, for example, memoizes partial reduction products in a b-tree,
enabling log-time updates to its reduced state when any given input key changes.
For an npm-managed project,
npm install @swim/streamlet to make it a
dependency. TypeScript sources will be installed into
definition files install into
And a pre-built UMD script can be found in
Web applications can load
swim-core.js, which comes bundled with the
@swim/streamlet library, directly from the Swim CDN.
@swim/streamlet can be imported as an ES6 module from TypeScript and other
import * as streamlet from "@swim/streamlet";
@swim/streamlet can also be used as a CommonJS in Node.js applications.
var streamlet = require("@swim/streamlet");
When loaded by a web browser, the
swim-core.js script adds the
@swim/streamlet library exports to the global