Skip to main content

Events & errors

Pass the callbacks you need in the options of the constructor:

new MobbSign({
...options,
onDocumentLoaded: () => console.log('Document loaded'),
onSignatureAcquired: () => console.log('Signature acquired'),
onSignatureDiscarded: () => console.log('Signature discarded'),
onSignatureConfirmed: () => console.log('Signature confirmed'),
onDocumentSigned: () => console.log('Document signed'),
onDoneButtonShown: () => console.log('Finish button shown'),
onDone: () => console.log('Process finished'),
onError: (error) => console.error('MobbSign error', error),
}).then((mobbsign) => mobbsign.load(documentId));
CallbackCalled when
onDocumentLoadedA document has been loaded and shown.
onSignatureAcquiredThe signer has drawn a signature. It can still be confirmed or discarded.
onSignatureDiscardedThe signer has discarded the signature.
onSignatureConfirmedThe signer has confirmed the signature, before the document is signed.
onDocumentSignedThe document has been signed.
onDoneButtonShownThe Finish button has been shown. Since version 2.2.0.
onDoneThe signer has finished the process.
onErrorAn error has occurred.

Handle errors​

Every error is reported to onError, which receives the error as its parameter. Log it and show the user a message that lets them retry:

new MobbSign({
...options,
onError: (error: unknown) => {
console.error('MobbSign error', error);
showMessage('The document could not be signed. Please try again.');
},
});