Skip to main content

Instance class

📖 Description

The Instance class holds all the data of a single active form instance. It manages the progress in the virtual finite state machine that is generated by the Runner class for the supplied form definition. The instance also contains the actual data that is collected by the form.

info

You always need to use the start or restore method of the Runner class to construct new form instances.

If you use one of the stock runners, instances are constructed automatically for you.

🗃️ Fields


🏷️ checksum

Retrieves a checksum for the form instance.

Type

string


🏷️ data

Retrieves the collected data for the form.

Type

Data


🏷️ fingerprint

Retrieves the fingerprint of the form.

Type

string

tip

More information in the form fingerprint guide.


🏷️ finishReference

Retrieves the optional reference that is returned by the finish event handler (for example, the server identifier of the form submission).

Type

string


🏷️ hasDataCollected

Retrieves if the form has any data collected.

Type

boolean


🏷️ id

Retrieves the form instance identifier.

Type

string


🏷️ isAtFinish

Retrieves if the form instance is at the finish.

Type

boolean


🏷️ isAtHead

Retrieves if the form instance is at the head, which is the furthest point in the form that has been reached.

Type

boolean


🏷️ isAtStart

Retrieves if the form instance is at the start (the beginning of the form).

Type

boolean


🏷️ isFinishable

Retrieves if the form instance is finishable using the finish method. This means the form is at the end and passes validation.

Type

boolean


🏷️ isFinished

Retrieves if the form instance has finished.

Type

boolean


🏷️ isFinishing

Retrieves if the form instance is finishing.

Type

boolean


🏷️ isInitialized

Retrieves if the form instance is initialized.

Type

boolean


🏷️ isPaused

Retrieves if the form instance is paused.

Type

boolean


🏷️ isPausing

Retrieves if the form instance is being paused.

Type

boolean


🏷️ isPreview

Retrieves if the preview mode is enabled for the form instance.

Type

boolean


🏷️ isRunning

Retrieves if the form instance is running.

Type

boolean


🏷️ isStopped

Retrieves if the form instance is stopped.

Type

boolean


🏷️ l10n

Retrieves the localization namespace with helper functions for working with translations and locales.

Type

L10n.Namespace


🏷️ snapshot

Retrieves the instance snapshot.

Type

IInstanceSnapshot

▶️ Methods


🔧 finish

Finish the form instance when it is at the end and there are slots collected.

Signature

finish(): Promise<void>

Return value

Returns a Promise that resolves when the form is finished or rejects when the form could not be completed.


🔧 pause

Pauses the instance.

Signature

pause(): IInstanceSnapshot | undefined

Return value

Returns the IInstanceSnapshot object or undefined if the instance could not be paused or was not running.


🔧 restart

Restarts the form instance.

Signature

restart(): void

🔧 start

Starts the form instance.

Signature

start(): boolean

Return value

Returns true if the instance is started.


🔧 stencil

Calculates the form stencil hash for the specified type. The form data stencil is a set of two hashes calculated from the form definition. Those data stencil hashes remain stable as long as the data fields generated when running the form definition remain the same. This is different than the fingerprint hash, which remains stable as long as the structure of the form stays the same.

Signature

stencil(type?: "exportables" | "actionables"): string

Parameters

NameTypeOptionalDescription
type"exportables" | "actionables"YesSpecifies the stencil type. It can be one of the following values:
- exportables: Generates the hash for all exportable fields (this is the default type);
- actionables: Generates the hash for all actionable fields.

Return value

Returns the stencil hash.

tip

More information about the stencil hashes in the form data stencil guide. More information about exportable vs. actionable data can be found here.


🔧 stepBackward

Step backward in the form.

Signature

stepBackward(): boolean

Return value

Returns true if the step succeeded.


🔧 stepForward

Step forward in the form.

Signature

stepForward(): boolean

Return value

Returns true if the step succeeded.


🔧 stepToHead

Step to the head of the form. This is the furthest point in the form that has been reached.

Signature

stepToHead(): boolean

Return value

Returns true if the step succeeded.


🔧 stepToStart

Step to the beginning of the form.

Signature

stepToStart(): boolean

Return value

Returns true if the step succeeded.


🔧 stop

Stops the instance.

Signature

stop(): boolean

Return value

Returns true if the instance was running and is stopped.