IStoryline interface
đ Descriptionâ
Interface that describes the immutable representation of the storyline.
đ Type declarationâ
interface IStoryline { moments: Moment[];Readonly pages: { number: number; active: boolean; activate: () => void; }[];Readonly presentMoment: Moment | undefined;Readonly presentCluster: Cluster | undefined;Readonly presentNodes: IObservableNode[];Readonly activeNodes: IObservableNode[];Readonly uniqueNodes: IObservableNode[];Readonly isEvaluating: boolean;Readonly isEmpty: boolean;Readonly isAtStart: boolean;Readonly isAtHead: boolean;Readonly isAtFinish: boolean;Readonly isFinishable: boolean;Readonly isFinishing: boolean;Readonly isFinished: boolean;Readonly isPausing: boolean;Readonly isPaused: boolean;Readonly hasDataCollected: boolean;Readonly isFailed: boolean;Readonly isPassed: boolean;Readonly mode: "paginated" | "continuous" | "progressive";Readonly direction: "forward" | "backward";Readonly count: number;Readonly enumerators: number;Readonly percentage: number;Readonly stepForward: () => boolean;Function stepBackward: () => boolean;Function stepToStart: () => boolean;Function stepToHead: () => boolean;Function stepToPage: (page: number) => boolean;Function finish: () => Promise<void> | false;Function map: <R>(fn: (moment: Moment, index: number) => R) => R[];Function }
đī¸ Propertiesâ
đˇī¸ activeNodesâ
Retrieves the observable nodes of the active moment (so the nodes of all moments in the moments collection).
Typeâ
đˇī¸ 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
đˇī¸ hasDataCollectedâ
Retrieves if the storyline has any data collected.
Typeâ
boolean
đˇī¸ 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.
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â
đˇī¸ pagesâ
Retrieves the collection of pages.
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.
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â
đˇī¸ uniqueNodesâ
Retrieves all the unique observable nodes of the active moments.
Typeâ
âļī¸ Functionsâ
đ§ finishâ
Finish the storyline when it is at the end.
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.
đ§ mapâ
Maps moments of the storyline to a certain type.
Signatureâ
map<R>(fn: (moment: Moment, index: number) => R): R[]
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
fn | (moment: Moment, index: number) => R | No | Specifies 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.
Only available for runners in paginated mode.
Signatureâ
stepToPage(page: number): boolean
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
page | number | No | Specifies 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.