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

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 mq.Handler details

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