Version0 /
OutputOverviewAn accessor may define any number of outputs in the body of its
For example: exports.setup = function() { output('price', { 'type':'number' }); } The output() function takes one or two arguments, a name (a required string, recommended to be camelCase with a leading lower-case character) and an object with any of the following options:
The name is required to be distinct from other inputs, outputs, and parameters. It may match the name of an output in a base accessor (specified by either extend() or implement()), in which case the options will override those specified in the base. Sending to OutputsAn accessor may use the send() function to send values via its output ports. This may be done in a callback function, such as a function passed to setTimeout or addInputHandler (see Top-Level Java Script Functions). For example, suppose that the following line is executed in a callback: send('price', 42); This will send the number 42 to the price output. If you send a null value to an output, and that output is connected to an input x of a downstream accessor, then that accessor's input handler will get null when it invokes get('x'). Note that if the output data type is JSON, then the JavaScript value will be converted to a JSON string before sending. This can be confusing. Specifically, if you want to send, say, send('output', {"foo": 42}); and not send('output', '{"foo": 42}'); In other words, do not convert your object to a JSON string yourself. See Also |