Object built-in object

Object Chain

Message processor chain processing object

The message processor chain processing object is used to link a series of message processors, and chain processing in a specified order. Creation method:

1 2 3
var chain = new mq.Chain([ func1, func2 ]);

Inheritance

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<class>Handler|new Handler()|invoke()] [<this>Chain|new Chain()|append()] [object] <:- [Handler] [Handler] <:- [Chain] Handler new Handler() invoke() Chain new Chain() append() object toString() toJSON()

Constructor

Chain

Construct a message processor chain processing object

1
new Chain(Array hdlrs);

Call parameters:

  • hdlrs: Array, processor array

Member function

append

Add processor array

1
Chain.append(Array hdlrs);

Call parameters:

  • hdlrs: Array, processor array

Add a processor

1
Chain.append(Handler hdlr);

Call parameters:

  • hdlr: Handler, Built-in message processor, processing function, chain processing array, routing object, see details mq.Handler

invoke

Process a message or object

1
Handler Chain.invoke(object v) async;

Call parameters:

  • v: object, Specify the message or object to be processed

Return result:

  • Handler, Return to the next processor

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String Chain.toString();

Return result:

  • String, Returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value Chain.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, Returns a value containing JSON serializable