reagi.core documentation

Functions and types for functional reactive programming.

accum

(accum init stream)
Change an initial value based on an event stream of functions.

behavior

macro

(behavior & form)
Takes a body of expressions and yields a behavior object that will evaluate
the body each time it is dereferenced.

behavior-call

(behavior-call func)
Takes a zero-argument function and yields a Behavior object that will
evaluate the function each time it is dereferenced. See: behavior.

behavior?

(behavior? x)
Return true if the object is a behavior.

box

(box x)
Box a value to ensure it can be sent through a channel.

buffer

(buffer stream)(buffer n stream)
Buffer all the events in the stream. A maximum buffer size may be specified,
in which case the buffer will contain only the last n items. It's recommended
that a buffer size is specified, otherwise the buffer will grow without limit.

complete?

(complete? signal)
True if the signal's value will no longer change.

completed

(completed x)
Wraps x to guarantee that it will be the last value in a behavior or event
stream. The value of x will be cached, and any values after x will be
ignored.

constantly

(constantly value stream)
Constantly map the same value over an event stream.

count

(count stream)
Return an accumulating count of the items in a stream.

cycle

(cycle values stream)
Incoming events cycle a sequence of values. Useful for switching between
states.

deliver

(deliver stream & msgs)
Deliver one or more messages to an event stream.

delta

(delta)
Return a behavior that tracks the time in seconds from when it was created.

dispose

(dispose x)
Clean up any resources an object has before it goes out of scope. In
Clojure this is called automatically when the object is finalized. In
ClojureScript this must be called manually.

events

(events)(events init)
Create a referential stream of events. An initial value may optionally be
supplied, otherwise the stream will be unrealized until the first value is
pushed to it. Event streams will deref to the latest value pushed to the
stream.

events?

(events? x)
Return true if the object is a stream of events.

filter

(filter pred stream)
Filter a stream by a predicate.

flatten

(flatten stream)
Flatten a stream of streams into a stream that contains all the values of
its components.

join

(join & streams)
Join several streams together. Events are delivered from the first stream
until it is completed, then the next stream, until all streams are complete.

listen

(listen ob ch)
Add a listener channel to the observable. The channel will be closed
when the port of the observable is closed. Returns the channel.

Any events sent to the channel will be boxed to protect the channel from
nils. To listen for unboxed events, use subscribe.

map

(map f & streams)
Map a function over a stream.

mapcat

(mapcat f stream)(mapcat f stream & streams)
Mapcat a function over a stream.

merge

(merge & streams)
Combine multiple streams into one. All events from the input streams are
pushed to the returned stream.

on-dispose

(on-dispose x f)
Add a function to be called when the object is disposed.

once

(once value)
Create a completed event stream for a single value.

port

(port ob)
Return a write-only core.async channel. Any elements send to the port will
be distributed to the listener channels in parallel. Each listener must
accept before the next item is distributed.

reduce

(reduce f stream)(reduce f init stream)
Create a new stream by applying a function to the previous return value and
the current value of the source stream.

remove

(remove pred stream)
Remove all items in a stream the predicate matches.

sample

(sample interval-ms reference)
Turn a reference into an event stream by deref-ing it at fixed intervals.
The interval time is specified in milliseconds.

signal?

(signal? x)
True if the object is a behavior or event stream.

subscribe

(subscribe stream channel)
Deliver events on an event stream to a core.async channel. Returns the
channel.

The events from the stream cannot include nil. The channel will be closed when
the event stream is complete.

throttle

(throttle timeout-ms stream)
Remove any events in a stream that occur too soon after the prior event.
The timeout is specified in milliseconds.

time

A behavior that tracks the current time in seconds.

unbox

(unbox x)
Unbox a boxed value.

uniq

(uniq stream)
Remove any successive duplicates from the stream.

wait

(wait time-ms)
Returns a channel that will complete unrealized after specified number of
milliseconds.

zip

(zip & streams)
Combine multiple streams into one. On an event from any input stream, a
vector will be pushed to the returned stream containing the latest events
of all input streams.