Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

manuel/bucky-rdp

A trivial implementation of Reactive Demand Programming

manuel/bucky-rdp.json
{
"createdAt": "2015-06-15T16:42:02Z",
"defaultBranch": "master",
"description": "A trivial implementation of Reactive Demand Programming",
"fullName": "manuel/bucky-rdp",
"homepage": "https://www.npmjs.com/package/bucky-rdp",
"language": "JavaScript",
"name": "bucky-rdp",
"pushedAt": "2015-07-18T11:54:35Z",
"stargazersCount": 8,
"topics": [],
"updatedAt": "2021-11-22T20:50:18Z",
"url": "https://github.com/manuel/bucky-rdp"
}

Build Status

A trivial implementation of Reactive Demand Programming for Node.js and Browserify.

Supports the following behaviors:

rdp.bConst(value)

While its input signal is active, produces an unchanging value as its output signal. Ignores the actual value of the input signal.

rdp.bPipe(b1, ..., bN)

A chain of one or more behaviors.

rdp.bFMap(function)

A behavior that applies a function to the value of its input signal, and uses the result as the value of its output signal.

var rdp = require("bucky-rdp");
// Create some behaviors for transforming numbers.
var bDouble = rdp.bFMap(function(val) { return val * 2; });
var bMinusOne = rdp.bFMap(function(val) { return val - 1; });
// Create a pipeline behavior of the two behaviors
var myBehavior = rdp.bPipe(bDouble, bMinusOne);
// Apply an inactive input signal to the pipeline behavior
var sigIn = rdp.makeSignal();
var sigOut = rdp.apply(myBehavior, sigIn);
// Change the input signal value and watch the output signal change
sigIn.setValue(2);
console.log(sigOut.getValue()); // Prints 3
sigIn.setValue(4);
console.log(sigOut.getValue()); // Prints 7
sigIn.deactivate();

MIT