For the complete documentation index, see llms.txt. This page is also available as Markdown.

Event listeners

The SDK provides various event listeners to handle different events during the document capture process. These listeners allow you to execute custom logic when specific events occur.

addEventListener

The addEventListener method is used to listen to events of the specified type.

documentDetector.addEventListener(type, listener, options);

Parameters

  • type (EventType): The type of event to listen for (check EventType for details).

  • listener (function): The function to be executed when the event is triggered.

  • options (object, optional): Additional options for the event listener

removeEventListener

The removeEventListener method is used to remove an event listener of the specified type.

documentDetector.removeEventListener(type, callback, options);

Parameters

  • type (EventType): The type of event to listen for (check EventType for details).

  • callback (function): The function to be removed.

  • options (object, optional): Additional options for the event listener

EventType

Type

Description

"front_capture_started"

Triggered when the capture of the front of the document has started.

"back_capture_started"

Triggered when the capture of the back of the document has started.

"capture_invalid"

Triggered when an error occurs in some validation performed by the SDK.

"capture_failed"

Triggered when an error occurs that is not handled by the SDK.

"capture_ready"

Triggered when the SDK capture screen (camera preview or upload UI) is rendered and ready for user interaction.

Event detail: mode, expectedDocumentType, expectedDocumentSide.

"upload_button_clicked"

Triggered when the user clicks the upload button in upload mode.

"capture_result"

Triggered after a document is successfully captured and validated.

Event detail: mode, isValid, expectedDocumentType, expectedDocumentSide.

Example

Last updated