Object built-in object

Object Chain

message handler chain processing object

The message handler chain processing object is used to link a series of message handlers and process them in a chain according to the specified order. Create method:

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

inheritance relationship

#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

Constructs a message handler chain processing object

1
new Chain(Array hdlrs);

Call parameters:

  • hdlrs: Array, array of handlers

member function

append

Add an array of processors

1
Chain.append(Array hdlrs);

Call parameters:

  • hdlrs: Array, array of handlers

add processor

1
Chain.append(Handler hdlr);

Call parameters:

  • hdlr:Handler, built-in message handlers, handler functions, chained processing arrays, routing objects, see detailsmq.Handler

invoke

handle a message or object

1
Handler Chain.invoke(object v) async;

Call parameters:

  • v:object, specifies the message or object to process

Return result:

  • Handler, return to the next handler

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be reimplemented 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 the set of readable properties defined by the object

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

Call parameters:

  • key: String, unused

Return result:

  • Value, returns a value containing JSON serializable