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));
| Callback | Called when |
|---|---|
onDocumentLoaded | A document has been loaded and shown. |
onSignatureAcquired | The signer has drawn a signature. It can still be confirmed or discarded. |
onSignatureDiscarded | The signer has discarded the signature. |
onSignatureConfirmed | The signer has confirmed the signature, before the document is signed. |
onDocumentSigned | The document has been signed. |
onDoneButtonShown | The Finish button has been shown. Since version 2.2.0. |
onDone | The signer has finished the process. |
onError | An 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.');
},
});