Class: EventsHandlers

EventsHandlers(setupopt)

Represents a handler for events related to a form.

Constructor

new EventsHandlers(setupopt)

Creates an instance of EventsHandlers.

Parameters:
Name Type Attributes Description
setup Object <optional>

The configuration for the instance.

Properties
Name Type Attributes Default Description
onStart function <optional>
async () => {}

The function to be called when the form starts.

onTrigger function <optional>
async () => {}

The function to be called when an event is triggered.

onNext function <optional>
async () => {}

The function to be called when the user goes to the next question.

onBack function <optional>
async () => {}

The function to be called when the user goes back to the previous question.

onChange function <optional>
async () => {}

The function to be called when the user changes an answer.

onRepeat function <optional>
async () => {}

The function to be called when the user wants to repeat a question.

onAnswer function <optional>
async () => {}

The function to be called when the user provides an answer.

onError function <optional>
async () => {}

The function to be called when an error occurs.

onEnd function <optional>
async () => {}

The function to be called when the form ends.

Source:

Methods

(async) answer(ev) → {*}

Handles the "answer" event and returns the event object.

Parameters:
Name Type Description
ev *

The event object.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log
Returns:
  • The event object.
Type
*

(async) back(ev) → {*}

Triggers the "back" event and logs a message to the console.

Parameters:
Name Type Description
ev *

The event object.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log
Returns:
  • The event object.
Type
*

(async) end(ev) → {Promise.<any>}

Handles end event.

Parameters:
Name Type Description
ev any

The event object.

Source:
Throws:

Throws an error if an error occurred while executing the event handler.

Type
Error
Returns:

Promise that resolves to the event object if the event was handled successfully.

Type
Promise.<any>

(async) error(ev, err) → {Promise.<any>}

Handles error event.

Parameters:
Name Type Description
ev any

The event object.

err Error

The error object.

Source:
Throws:

Throws an error if an error occurred while executing the event handler.

Type
Error
Returns:

Promise that resolves to the event object if the event was handled successfully.

Type
Promise.<any>

(async) next(ev) → {*}

Triggers the "next" event and returns the event object.

Parameters:
Name Type Description
ev *

The event object.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log
Returns:
  • The event object.
Type
*

(async) repeat(ev) → {*}

Triggers the "repeat" event and logs a message to the console.

Parameters:
Name Type Description
ev *

The event object.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log
Returns:
  • The event object.
Type
*

(async) start(ev) → {*}

Starts the event and returns the event object.

Parameters:
Name Type Description
ev *

The event object.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log
Returns:
  • The event object.
Type
*

(async) trigger(ev) → {*}

Triggers the event and returns the event object.

Parameters:
Name Type Description
ev *

The event object.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log
Returns:
  • The event object.
Type
*

(async) triggerEvent(eventName, …args)

Triggers a specified event with optional parameters.

Parameters:
Name Type Attributes Description
eventName QuestionModel

The Question event that triggered the event

args * <repeatable>

The event name and any optional parameters.

Source:
Throws:
  • If an error occurs while handling the event.
Type
Error.Log