API for dataflow
(master branch)
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
Source
add-cells
function
Usage: (add-cells df cells)
Given a collection of cells, add them to the dataflow.
Source
build-dataflow
function
Usage: (build-dataflow cs)
Given a collection of cells, build and return a dataflow object
Source
build-source-cell
function
Usage: (build-source-cell name init)
Builds a source cell
Source
build-standard-cell
function
Usage: (build-standard-cell name deps fun expr)
Builds a standard cell
Source
build-validator-cell
function
Usage: (build-validator-cell deps fun expr)
Builds a validator cell
Source
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
Source
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
Source
get-cells
function
Usage: (get-cells df name)
Get all the cells named by name
Source
get-old-value
function
Usage: (get-old-value df env name)
Looks up an old value
Source
get-source-cells
function
Usage: (get-source-cells df)
Returns a collection of source cells from the dataflow
Source
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.
Source
get-value-from-cell
function
Usage: (get-value-from-cell cell)
Given a cell, get its value
Source
get-values
function
Usage: (get-values df name)
Gets a collection of values from the df by name
Source
print-dataflow
function
Usage: (print-dataflow df)
Prints a dataflow, one cell per line
Source
remove-cells
function
Usage: (remove-cells df cells)
Given a collection of cells, remove them from the dataflow.
Source
source-cell?
function
Usage: (source-cell? cell)
Is this cell a source cell?
Source
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
Source