new ContractEventListener(contract, listenerName, eventName, eventCallback, options)
Constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
contract |
Contract | The contract instance |
listenerName |
string | a unique name identifying the listener |
eventName |
string | The name of the contract event being listened for |
eventCallback |
function | The event callback called when an event is received. It has signature (err, BlockEvent, blockNumber, transactionId) |
options |
module:fabric-network.Network~ListenerOptions |
Methods
-
<async> _onError(error)
-
This callback is triggered when the event was unsuccessful. If the error indicates that the event hub shutdown and the listener is still registered, it updates the EventHubSelectionStrategy status of event hubs (if implemented) and finds a new event hub to connect to
Parameters:
Name Type Description errorError The error emitted -
<async> _onEvent(event, blockNumber, transactionId, status [, expectedNumber])
-
The callback triggered when the event was successful. Checkpoints the last block and transaction seen once the callback has run and unregisters the listener if the unregister flag was provided
Parameters:
Name Type Argument Description eventChaincodeEvent the event emitted blockNumberString the block number this transaction was committed inside transactionIdstring the transaction ID of the transaction this event was emitted by statusstring the status of the the transaction expectedNumberstring <optional>
the expected number of events from the block -
<async> register()
-
Finds and connects to an event hub then creates the listener registration
-
unregister()
-
Unregisters the registration from the event hub