Version1 /
OutputOverviewAn accessor may define any number of outputs in the body of its
For example: exports.setup = function() { this.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 (see Top-Level Java Script Functions) or addInputHandler (see ). For example, suppose that the following line is executed in a callback: this.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, this.send('output', {"foo": 42}); and not this.send('output', '{"foo": 42}'); In other words, do not convert your object to a JSON string yourself. If you call send() multiple times before the receiving accessor has a chance to react to the data, then the data will be queued and will cause multiple reactions of the downstream accessor, one for each send(). See Also |