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 presentSection: Section | undefined;Readonly presentNodes: IObservableNode[];Readonly all: (IObservableNode & { bookmark: IBookmark; })[];Readonly nodes: IObservableNode[];Readonly bookmarks: IBookmark[];Readonly slides: ISlide[];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" | "ahead";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â
đˇī¸ allâ
Retrieves all observable nodes of the active moment (so the nodes of all moments in the moments collection) with their corresponding bookmark.
Typeâ
(IObservableNode & { bookmark: IBookmark })[]
đˇī¸ bookmarksâ
Retrieves the bookmarks in the storyline.
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 section on a separate page (this is the default behavior);continuous: Render all completed (past) sections and the current (present) section on a page;progressive: Render all completed (past), current (present) and future sections on a page till the point where one of the sections fails validation;ahead: Render all completed (past), current (present) and future sections on a page, regardless of the section's validation result.
Typeâ
"paginated" | "continuous" | "progressive" | "ahead"
đˇī¸ 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 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â
đˇī¸ nodesâ
Retrieves the observable nodes of the active moment (so the nodes of all moments in the moments collection).
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
đˇī¸ presentMomentâ
Retrieves the present moment.
Typeâ
Moment | undefined
đˇī¸ presentNodesâ
Retrieves the observable nodes of the present moment.
Typeâ
đˇī¸ presentSectionâ
Retrieves the section of the present moment.
Typeâ
Section | undefined
đˇī¸ slidesâ
Retrieves the slides in the storyline.
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.