cargo.pollTx

After enabling Cargo you can use the PollTx instance on the enabled Cargo instance. You can use the methods of the PollTx class to watch pending transactions and notify you when they are complete. Here is the source on GitHub.

Using PollTx

Here is an example of how you might use PollTx in an application

async function purchaseAnItem(resaleItemId, price) {
const tx = await cargo.api.purchaseResaleToken(resaleItemId, price);
// This method takes the transaction hash of the submitted transaction
// and starts watching for the completion of the transaction.
cargo.pollTx.watch(tx);
}
// Somewhere else in your application you can add event listeners
// to the PollTx instance that will tell you when the list of pending
// transactions has been updated and when a transaction is complete
cargo.pollTx.on('pendingUpdated', (pendingTxArray) => {
// pendingTxArray a list of transactions that are still pending
console.log(pendingTxArray);
});
cargo.pollTx.on('completed', (tx) => {
// tx is the completed transaction hash
console.log(tx);
})