rge.streak.streak.0.01.source-code.overview.html Maven / Gradle / Ivy
Show all versions of streak Show documentation
⚡ Streak ⚡ is a browser based reactive event stream library in the tradition of the
ReactiveX philosophy. Applications are created by composing
event streams and Streak shines when used to coordinate multiple independent event streams. The
library aims to simplify asynchronous programming and
minimize the hazards of side effects and mutable shared state.
The developer experience is a primary concern in Streak without sacrificing end-user experience. This
means that extensive invariant checking occurs in development mode but is optimized away in production
builds of the library. Streak is under heavy development, and sometimes the documentation does not keep
up to date. The goal of the library is to be easy to use, and this includes clear and concise documentation.
If something is unclear please report it as a bug
because it is a bug. If a new user has a hard time, then we need to fix the problem.
Streak was developed to be used within the browser. It is designed to be transpiled down to reasonably
efficient javascript with a small code size. Often the library chose a smaller code size over a better
runtime speed under the assumption that the browser speed is more likely to be negatively impacted by
increased code size due to download time, js parse time and js compile time than it would be due to a
slight runtime performance degradation although the {@link streak.Stream#compose(Function)} escape hatch has
been added so that users can write their own operators when performance is critical.
Concepts
Events
An event is an action or occurrence recognized by software that occurs at a particular instant in
time. An event can be thought of as a pair containing a value
element describing the event
data and a time
element that indicates the time at which the event is emitted. Both the value
and time elements are just as important.
An example of an event may be a network message. Another example is a user interaction such as a keypress
or a mouse button click. An event could also be triggered by passing of time in a timer such that an event
is generated every N
milliseconds.
Streams
A {@link streak.Stream stream} is a time-ordered sequence of events. For example, a stream of click
events from a UI control or a stream of messages over a WebSocket. Operators filter, transform and combine
input streams. An operator never modifies the input stream but instead creates a new stream.
A listener or a {@link streak.Subscriber subscriber} in Streak parlance receives the events and reacts to events
as they occur. The events are received in the order in which they are emitted and at the time they are emitted.
A stream can also send other signals to the subscriber indicating that the stream has
completed or that the stream has failed. If the subscriber receives these signals then they will not
receive any more events from the stream and must handle that appropriately. Thus streams may be infinite,
finite, or may fail.
Event Sources and Stream Operators
The library includes construction methods to create event sources combined with a powerful set of operators
for filtering, transforming and merging event streams. The construction methods and operators available are
as follows:
@@OPERATORS@@