Flow-based programming for JavaScript
required: true
the port needs to be connected in order for the component to workMultiError
pattern is enabled by default when using WirePattern
and supports forwardGroups
option for error packets.WirePattern
components now deal more consistently with groups and disconnect eventsicon
key in graph propertiesWirePattern
components, allowing them to have configuration parameters that need to be set only once. Example:component = new noflo.Component
component.inPorts.add 'path',
datatype: 'string'
required: true
component.inPorts.add 'delay',
datatype: 'int'
required: false
component.inPorts.add 'line',
datatype: 'string'
component.inPorts.add 'repeat',
datatype: 'int'
component.outPorts.add 'out',
datatype: 'object'
component.outPorts.add 'error',
datatype: 'object'
noflo.helpers.WirePattern component,
in: ['line', 'repeat']
out: 'out'
params: ['path', 'delay']
async: true
, (data, groups, out, callback) ->
path = component.params.path
delay = if component.params.delay then component.params.delay else 0
doSomeThing path, delay, data.line, data.repeat, (err, res) ->
return callback err if err
out.send res
callback()
shutdown
method which is called when they're removed from a networkproperties
keystart
and a stop
method for starting and stopping executiontrue
for isAttached
checks. There is a separate canAttach
method for checking whether more can be addednoflo.icon
key in your package.json
(Node.js libraries) or component.json
(browser libraries)icon
attributeshutdown
methodloadGraph
methodnoflo.loader
key in the manifest pointing to a CommonJS moduleerror
helper method for sending errors to the error
outport, or throwing them if that isn't attachedregisterLoader
method of NoFlo's ComponentLoadercontains
method for buffered inports returns the number of data packets the buffer haserror
outport of AsyncComponents now sends the group information of the original input together with the errorerror
method of regular ports can now also handle groups as a second parameterlistAttached
methodfunction
is now an accepted datatype for portsIn the FBP format, these can be specified with the bracket syntax:
SomeNode OUT[2] -> IN OtherNode
'foo' -> OPTS[1] OtherNode
In the JSON file these are defined in connections by adding a integer to the index
key of the src
or tgt
definition.
The NoFlo Graph class provides these with the following methods:
addEdgeIndex(str outNode, str outPort, int outIndex, str inNode, str inPort, int inIndex, obj metadata)
addInitiaIndex(mixed data, str inNode, str inPort, int inIndex, obj metadata)
If indexes are not specified, the fall-back behavior is to automatically index the connections based on next available slot in the port.
StreamSender
affecting WirePattern components dealing with multiple levels of groupingCustomizeError
helper for passing information with Error objects in NoFlo. For example:# Instantiate an error object
err = new Error 'Something went wrong'
# Add metadata to it. Usually this should include groups and other machine-readable information
noflo.helpers.CustomizeError err,
groups: groups
foo: 'bar'
# Send it to error port
c.error err
GroupedInput
helper has been renamed to WirePattern
due to a bigger collection of synchronization options.WirePattern
helper has a new ordered
option for choosing whether the output should be in same order as the incoming packetsgroup
and forwardGroups
of WirePattern
are made independent, so make sure to use forwardGroups: true
if you need this feature together with group: true
.WirePattern
.load
outport handing in WirePattern
to make it a complete replacement for AsyncComponent
.caching
option for OutPorts that makes them re-send their latest value to any newly-added connections, see #151 for example use cases.integer
is accepted as an alias for the int
datatype for portsbuffer
is now an accepted port datatypegetSource
method when invoked early on in executionThe MapComponent
helper is usable for synchronous components that operate on a single inport-outport combination:
c = new noflo.Component
inPorts:
in:
datatype: 'number'
outPorts:
out:
datatype: 'number'
noflo.helpers.MapComponent c, (data, groups, out) ->
out.send data * 2
The GroupedInput
helper assists in building components that need to synchronize multiple inputs by groups:
c = new noflo.Component
inPorts:
x:
datatype: 'number'
y:
datatype: 'number'
outPorts:
radius:
datatype: 'number'
noflo.helpers.GroupedInput c,
in: ['x', 'y']
out: 'radius'
, (data, groups, out) ->
out.send Math.sqrt(data.x**2 + data.y**2)
GroupedInput
can also synchronize via specific fields of object-type packets:
helpers.GroupedInput c,
in: ['user', 'message']
out: 'signedMessage'
field: 'request'
, (data, groups, out) ->
out.send
request: data.request
user: data.user.name
text: data.message.text
user.send {request: 123, id: 42, name: 'John'}
message.send {request: 123, id: 17, text: 'Hello world'}
# Result:
{ request: 123, user: 'John', text: 'Hello world'}