Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Register onError handler with Deposit autoSubmit function #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Mar 22, 2021

This PR is a follow-up from https://github.com/keep-network/tbtc.js/pull/118/files#r578527898.

We let onError handling function be provided with autoSubmit function so it's not necessary to call a separate function to register it. The argument is optional.

We let onError handling function to be provided with autoSubmit function
so it's not necessary to call a separate function to register it. The
argument is optional.

if (onError) {
this.eventEmitter.on("error", onError)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't what I'd call the expected behavior, fwiw, because this keeps the error handler registered. Passing it to the function implies a single-shot usage. You could use .one here, but if there's no error invoked later on then that could lead to an unexpected call with a future error event.

I would just invoke this in the same place we trigger the event below, if it's defined.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants