Skip to content
Ulric Wilfred edited this page Jan 31, 2015 · 4 revisions

Description

Stores the Node data. Manages inlets and outlets.

Events

  • node/turn-on() — fired when node was added to some model; {node}
  • node/ready() — fired when all inlets and outlets from node type definition were added to the node; {node}
  • node/process(Inlets, Outlets) — fired on any update in any of the inlets (unless they are "cold"), gets the hash-object of inlet values and the hash-object of outlet values; {inlets, outlets, node}
  • node/turn-off() — fired when node was removed from some model; {node}
  • inlet/add(Inlet) — fired when inlet was added to this node; {inlet}
  • inlet/remove(Inlet) — fired when inlet was removed from this node; {inlet}
  • inlet/add(Outlet) — fired when outlet was added to this node; {outlet}
  • inlet/remove(Outlet) — fired when outlet was removed from this node; {outlet}

Methods

constructor

  • Node(type: String[, name: String]) — create a node by type, give it an optional name;

instance

  • node.turnOn() — turn this node on;
  • node.turnOff() — turn this node off;
  • node.addInlet(type: String, alias: String[, name: String][, default: Any])Inlet — add new inlet, by type and alias;
  • node.addOutlet(type: String, alias: String[, name: String][, default: Any])Outlet — add new outlet, by type and alias;
  • node.removeInlet(Inlet) — remove given inlet from this node;
  • node.removeOutlet(Outlet) — remove given outlet from this node;

Examples

Create node:

var node = new Rpd.Node('core/empty', 'Empty');

Create node and add an inlet:

var node = new Rpd.Node('core/custom');
var inlet = node.addInlet('core/number', 'num');

Subscribe to node/process event:

// there's no canvas renderer for now, it's just an example
var model = Rpd.Model.start('my-model')
                     .renderWith('canvas')
                     .attachTo(document.body);
var node = new Rpd.Node('core/custom', 'Custom');
node.event['node/process'].onValue(function(vals) {
    var inlets = vals[0],
        outlets = vals[1],
        prev_inlets = vals[2];
    console.log(inlets, outlets, prev_inlets);
});
Clone this wiki locally