Adds event listener.
Events
Event name
Event handler
For debugging, logs all pending requests and their time to expiry
Stops the maintenance loop and cleans up resources. Should be called when done using the matcher.
ProtectedfireFire event
Type of event
Arguments for event
Remove event listener
Response has been received
Response
True if response matched a request
Matches responses with requests, expiring requests if they do not get a response in a timely manner.
Basic usage:
It's also possible to wait for specific replies:
It relies on creating an id of a request/response for them to be matched up. Use the
keyoption if the function can generate a key from either request or response. Or alternatively set bothkeyRequestandkeyResponsefor two functions that can generate a key for request and response respectively.The easy case is if req & resp both have the same field:
A more complicated case:
By default, error will be thrown if a response is received that doesn't match up to any request.