Skip to main content

Storyline class

๐Ÿ“– Descriptionโ€‹

The Storyline class helps to render runners by supplying all the required properties and methods for rendering the form.

๐Ÿ—ƒ๏ธ Fieldsโ€‹


๐Ÿท๏ธ activeNodesโ€‹

Retrieves the observable nodes of the active moment (so the nodes of all moments in the moments collection).

Typeโ€‹

IObservableNode[]


๐Ÿท๏ธ activePageโ€‹

Retrieves the active page.

caution

Only available for runners in paginated mode.

Typeโ€‹

{
/* Contains the page number. */
number: number;
} | undefined

๐Ÿท๏ธ checksumโ€‹

Retrieves the checksum of the storyline.

Typeโ€‹

string | undefined


๐Ÿท๏ธ countโ€‹

Retrieves the total number of observable nodes in the storyline.

Typeโ€‹

number


๐Ÿท๏ธ directionโ€‹

Retrieves the most recent step direction of the storyline.

Typeโ€‹

"forward" | "backward"


๐Ÿท๏ธ enumeratorsโ€‹

Retrieves the total number of observable nodes that have an enumerator value.

Typeโ€‹

number


๐Ÿท๏ธ epilogueโ€‹

Retrieves the optional epilogue for the form. This epilogue can be used by runners (that support it) to show a closing message when the form is completed.

Typeโ€‹

IEpilogue


๐Ÿท๏ธ hasDataCollectedโ€‹

Retrieves if the storyline has any data collected.

Typeโ€‹

boolean


๐Ÿท๏ธ immutableโ€‹

Retrieves an immutable representation of the storyline.

Typeโ€‹

IStoryline


๐Ÿท๏ธ instanceโ€‹

Retrieves the instance of the storyline.

Typeโ€‹

Instance


๐Ÿท๏ธ isAtFinishโ€‹

Retrieves if the present moment is at the finish of the storyline.

Typeโ€‹

boolean


๐Ÿท๏ธ isAtHeadโ€‹

Retrieves if the present moment is at the head of the storyline.

Typeโ€‹

boolean


๐Ÿท๏ธ isAtStartโ€‹

Retrieves if the present moment is at the beginning of the storyline.

Typeโ€‹

boolean


๐Ÿท๏ธ isChangedโ€‹

Retrieves if the storyline has changed since the last call of this prop.

Typeโ€‹

boolean


๐Ÿท๏ธ isEmptyโ€‹

Retrieves if the storyline is empty (has no observable nodes, basically an empty form).

Typeโ€‹

boolean


๐Ÿท๏ธ isEvaluatingโ€‹

Retrieves if the storyline is evaluating.

Typeโ€‹

boolean


๐Ÿท๏ธ isFailedโ€‹

Retrieves if the validation of the storyline failed.

Typeโ€‹

boolean


๐Ÿท๏ธ isFinishableโ€‹

Retrieves if the storyline is finishable using the finish method.

Typeโ€‹

boolean


๐Ÿท๏ธ isFinishedโ€‹

Retrieves if the storyline is finished.

Typeโ€‹

boolean


๐Ÿท๏ธ isFinishingโ€‹

Retrieves if the storyline is finishing.

Typeโ€‹

boolean


๐Ÿท๏ธ isPassedโ€‹

Retrieves if the validation of the storyline passed.

Typeโ€‹

boolean


๐Ÿท๏ธ isPausedโ€‹

Retrieves if the storyline is paused.

Typeโ€‹

boolean


๐Ÿท๏ธ isPausingโ€‹

Retrieves if the storyline is pausing.

Typeโ€‹

boolean


๐Ÿท๏ธ modeโ€‹

Retrieves the mode of operation. It can be one of the following values:

  • paginated: Render each cluster on a separate page (this is the default behavior);
  • continuous: Render all completed (past) clusters and the current (present) cluster on a page;
  • progressive: Render all completed (past), current (present) and future clusters on a page.

Typeโ€‹

"paginated" | "continuous" | "progressive"


๐Ÿท๏ธ momentsโ€‹

Retrieves the moments that are in the storyline. There are three types of moments:

  • Past moments;
  • The present moment;
  • Future moments.
info

The best way to understand these moment types is to visualize a paginated form runner, where the questions (node blocks) are presented on a page. Each cluster (section) is a page. All pages that are already answered by the respondent are past moments. The current page the respondent is on is the present moment. And all the pages the respondent still needs to answer are future moments.

Typeโ€‹

Moment[]


๐Ÿท๏ธ pagesโ€‹

Retrieves the collection of pages.

caution

Only available for runners in paginated mode.

Typeโ€‹

{
/* Contains the page number. */
number: number;

/* Contains if the page is active. */
active: boolean;

/* Activates the page. */
activate: () => void;
}[]

๐Ÿท๏ธ percentageโ€‹

Retrieves the progress percentage of the storyline.

tip

Can be used to show a progressbar that indicates the progress of the form.

Typeโ€‹

number


๐Ÿท๏ธ presentClusterโ€‹

Retrieves the cluster (section) of the present moment.

Typeโ€‹

Cluster | undefined


๐Ÿท๏ธ presentMomentโ€‹

Retrieves the present moment.

Typeโ€‹

Moment | undefined


๐Ÿท๏ธ presentNodesโ€‹

Retrieves the observable nodes of the present moment.

Typeโ€‹

IObservableNode[]


๐Ÿท๏ธ prologueโ€‹

Retrieves the optional prologue for the form. This prologue can be used by runners (that support it) to show a welcome message before starting the actual form.

Typeโ€‹

IPrologue


๐Ÿท๏ธ uniqueNodesโ€‹

Retrieves all the unique observable nodes of the active moments.

Typeโ€‹

IObservableNode[]

โ–ถ๏ธ Methodsโ€‹


๐Ÿ”ง finishโ€‹

Finish the storyline when it is at the end.

caution

You can only finish a form when it is finishable.

Signatureโ€‹

finish(): Promise<void>

Return valueโ€‹

Returns a Promise that resolves when the instance was finished. The finish operation can be asynchronous. For example, when the form submits data to an endpoint. During the finish operation you could show a visual indicator to the respondent to indicate the form is submitting. When the promise resolves or rejects, the finish operation ends. When the promise rejects, the form remains active and the respondent should be able to try to finish the form again.


๐Ÿ”ง getKeyByNodeIdโ€‹

Find the node that belongs to the supplied node identifier.

Signatureโ€‹

getKeyByNodeId(id: string): IObservableNode | undefined

Parametersโ€‹

NameTypeOptionalDescription
idstringNoSpecifies the node identifier.

Return valueโ€‹

Returns the IObservableNode object or undefined if the node was not found.


๐Ÿ”ง getNodeByKeyโ€‹

Find the node that belongs to the supplied key.

Signatureโ€‹

getNodeByKey(key: string): IObservableNode | undefined

Parametersโ€‹

NameTypeOptionalDescription
keystringNoSpecifies the node key.

Return valueโ€‹

Returns the IObservableNode object or undefined if the node was not found.


๐Ÿ”ง mapโ€‹

Maps moments of the storyline to a certain type.

Signatureโ€‹

map<R>(fn: (moment: Moment, index: number) => R): R[]

Parametersโ€‹

NameTypeOptionalDescription
fn(moment: Moment, index: number) => RNoSpecifies the map function.

Return valueโ€‹

Returns the resulting array of the map operation.


๐Ÿ”ง stepBackwardโ€‹

Step backward in the storyline.

Signatureโ€‹

stepBackward(): boolean

Return valueโ€‹

Returns true if the step succeeded.


๐Ÿ”ง stepForwardโ€‹

Step forward in the storyline.

Signatureโ€‹

stepForward(): boolean

Return valueโ€‹

Returns true if the step succeeded.


๐Ÿ”ง stepToHeadโ€‹

Step to the head of the storyline.

Signatureโ€‹

stepToHead(): boolean

Return valueโ€‹

Returns true if the step succeeded.


๐Ÿ”ง stepToPageโ€‹

Steps to a page.

caution

Only available for runners in paginated mode.

Signatureโ€‹

stepToPage(page: number): boolean

Parametersโ€‹

NameTypeOptionalDescription
pagenumberNoSpecifies the page to step to.

Return valueโ€‹

Returns true if the step succeeded.


๐Ÿ”ง stepToStartโ€‹

Step to the start of the storyline.

Signatureโ€‹

stepToStart(): boolean

Return valueโ€‹

Returns true if the step succeeded.