control-rod-assembly

Control structure for connecting and disconnecting multiple ControlRods at once

npm install control-rod-assembly
3 downloads in the last week
5 downloads in the last month

control-rod-assembly

Stability: 1 - Experimental

NPM version

Control structure for connecting and disconnecting multiple ControlRods at once.

Usage

var ControlRod = require('control-rod'),
    ControlRodAssembly = require('control-rod-assembly'),
    events = require('events');

var emitter1 = new events.EventEmitter();
var emitter2 = new events.EventEmitter();
var emitter3 = new events.EventEmitter();

var rod1 = new ControlRod(emitter1, 'foo', function () { /* ... */ });
var rod2 = new ControlRod(emitter1, 'bar', function () { /* ... */ });
var rod3 = new ControlRod(emitter2, 'foo', function () { /* ... */ });
var rod4 = new ControlRod(emitter2, 'bar', function () { /* ... */ });
var rod5 = new ControlRod(emitter3, 'foo', function () { /* ... */ });
var rod6 = new ControlRod(emitter3, 'bar', function () { /* ... */ });
var rod7 = new ControlRod(emitter3, 'baz', function () { /* ... */ });

var rodAssembly = new ControlRodAssembly(rod1, rod2, rod3, rod4, rod5);
rodAssembly.add(rod6, rod7);

rodAssembly.connect();
// all rods are connected
rodAssembly.disconnect();
// all rods are disconnected

rodAssembly.rods();
// [rod1, rod2, rod3, rod4, rod5, rod6, rod7] array of rods in assembly

Test

npm test

Overview

ControlRodAssembly is an abstraction over a collection of ControlRods in order to connect and disconnect them together.

Documentation

ControlRodAssembly

Public API

new ControlRodAssembly(rod, [rod, ...])

  • rod, [rod, ...]: ControlRod Zero, one, or more control rods to initialize with.

Creates a new instance of ControlRodAssembly.

controlRodAssembly.add(rod, [rod, ...])

  • rod, [rod, ...]: ControlRod Zero, one, or more control rods to add.

Adds specified ControlRods to assembly.

controlRodAssembly.connect()

Connects all ControlRods in the assembly.

controlRodAssembly.disconnect()

Disconnects all ControlRods in the assembly.

controlRodAssembly.remove(rod, [rod, ...])

  • rod, [rod, ...]: ControlRod Zero, one, or more control rods to remove.

Removes specified ControlRods from assembly.

controlRodAssembly.rods()

  • Return: Array An array of ControlRods in this assembly.
npm loves you