d2fs.state.method
D2FSStateMethod : d2/sdk/controls/dialogs/generic/d2fs.state.method
D2FSStateMethod. A default, contextful implementation of state methods that makes it possible to retrieve and transition through different states of D2FS dialogs. To customize the default implementation with lesser amount of coding, this class can be extended into scenario specific subclass and added to state methods collection by means of extension with proper binding rules.
Also see DialogStateMethods
Extends: DialogStateMethod
- D2FSStateMethod :
d2/sdk/controls/dialogs/generic/d2fs.state.method
- .execute(options, result) ⇒
Promise.<boolean>
- .setDialogContextForm(dialogId, action, currentFormName) ⇒
void
- .getDialogContextForm(dialogId, action) ⇒
string
|null
- .clearDialogContextForm(dialogId) ⇒
void
- .getDialogAdditonalParams(options) ⇒
object
- .extractMergeableFormDataFromResponse(success) ⇒
object
- .execute(options, result) ⇒
d2FSStateMethod.execute(options, result) ⇒ Promise.<boolean>
Implements contextful state transition logic for D2FS dialog.
Kind: instance method of D2FSStateMethod
Returns: Promise.<boolean>
- Resolve with false
to stop executing any other matching state methods that are supposed to execute after it.
Param | Type | Description |
---|---|---|
options | MethodMetadata | holder for various current state related metadata |
result | OutputFormData | Output parameter, should be filled in with metadata pertaining to next possible state of the dialog. |
d2FSStateMethod.setDialogContextForm(dialogId, action, currentFormName) ⇒ void
Set the context before applying this method to current state of the dialog.
Kind: instance method of D2FSStateMethod
Param | Type | Description |
---|---|---|
dialogId | string | A unique identifier associated with current dialog. |
action | string | Name of the method getting applied |
currentFormName | string | Present state's metadata name for the dialog. |
d2FSStateMethod.getDialogContextForm(dialogId, action) ⇒ string
| null
Get context before applying this method to current state of the dialog.
Kind: instance method of D2FSStateMethod
Returns: string
| null
- Should return contextual state name, however can return null
to implement a contextless flow.
Param | Type | Description |
---|---|---|
dialogId | string | A unique identifier associated with current dialog. |
action | string | Name of the method about to be applied. |
d2FSStateMethod.clearDialogContextForm(dialogId) ⇒ void
Clears context for given dialog when the dialog has reached a terminal state.
Kind: instance method of D2FSStateMethod
Param | Type | Description |
---|---|---|
dialogId | string | A unique identifier associated with current dialog. |
d2FSStateMethod.getDialogAdditonalParams(options) ⇒ object
Prepares the set of attributes (key-value pairs) to be sent to Backend(REST-API) as additional attributes
Kind: instance method of D2FSStateMethod
Returns: object
- Should return a simple JSON object having key-value pairs. All the members of this object is serialized as additional parameter before they are sent to Backend.
Param | Type | Description |
---|---|---|
options | MethodMetadata | holder for various current state related metadata. It is the same |
d2FSStateMethod.extractMergeableFormDataFromResponse(success) ⇒ object
Extracts flow-back properties from the success
response of a Backend(REST-API) method execution such that those properties are saved as part of the input form data.
Kind: instance method of D2FSStateMethod
Returns: object
- Should return a simple JSON object having key-value pairs. The members of the object is merged onto the same input form data that was earlier passed to Backend.
Param | Type | Description |
---|---|---|
success | object | JSON converted success response received after Backend invocation. |