API for dataflow
- ()
by Jeffrey Straszheim
Usage:
(ns your-namespace
(:require clojure.contrib.dataflow))
Overview
A library to support a dataflow model of state
Public Variables and Functions
add-cell-watcher
function
Usage: (add-cell-watcher cell key fun)
Adds a watcher to a cell to respond to changes of value. The is a
function of 4 values: a key, the cell, its old value, its new
value. This is implemented using Clojure's add-watch to the
underlying ref, and shared its sematics
add-cells
function
Usage: (add-cells df cells)
Given a collection of cells, add them to the dataflow.
build-dataflow
function
Usage: (build-dataflow cs)
Given a collection of cells, build and return a dataflow object
build-source-cell
function
Usage: (build-source-cell name init)
Builds a source cell
build-standard-cell
function
Usage: (build-standard-cell name deps fun expr)
Builds a standard cell
build-validator-cell
function
Usage: (build-validator-cell deps fun expr)
Builds a validator cell
cell
macro
Usage: (cell type & data)
Build a standard cell, like this:
(cell fred
(* ?mary ?joe))
Which creates a cell named fred that is the product of a cell mary and cell joe
Or:
(cell joe
(apply * ?*sally))
Which creates a cell that applies * to the collection of all cells named sally
Or:
(cell :source fred 0)
Which builds a source cell fred with initial value 0
Or:
(cell :validator (when (< ?fred ?sally)
(throwf "%s must be greater than %s" ?fred ?sally))
Which will perform the validation
display-cell
multimethod
No usage documentation available
A 'readable' form of the cell
Source
eval-cell
multimethod
No usage documentation available
Evaluate a dataflow cell. Return [changed, old val]
Source
get-cell
function
Usage: (get-cell df name)
Get the single cell named by name
get-cells
function
Usage: (get-cells df name)
Get all the cells named by name
get-old-value
function
Usage: (get-old-value df env name)
Looks up an old value
get-source-cells
function
Usage: (get-source-cells df)
Returns a collection of source cells from the dataflow
get-value
function
Usage: (get-value df name)
Gets a value from the df matching the passed symbol.
Signals an error if the name is not present, or if it not a single
value.
get-value-from-cell
function
Usage: (get-value-from-cell cell)
Given a cell, get its value
get-values
function
Usage: (get-values df name)
Gets a collection of values from the df by name
print-dataflow
function
Usage: (print-dataflow df)
Prints a dataflow, one cell per line
remove-cells
function
Usage: (remove-cells df cells)
Given a collection of cells, remove them from the dataflow.
source-cell?
function
Usage: (source-cell? cell)
Is this cell a source cell?
update-values
function
Usage: (update-values df data)
Given a dataflow, and a map of name-value pairs, update the
dataflow by binding the new values. Each name must be of a source
cell