# delay

## Description

Inserts a delay before executing another function.

## Input / Parameter

| Name       | Description                                               | Input Type | Default | Options     | Required |
| ---------- | --------------------------------------------------------- | ---------- | ------- | ----------- | -------- |
| duration   | The time before a function is executed. (In milliseconds) | Number     | -       | -           | Yes      |
| persistent | To still execute outside of the current page or not.      | Boolean    | False   | False, True | No       |
| extra      | The stored value that is passed to all the callbacks.     | Any        | -       | -           | No       |

## Output

Returns formatted information.

## Callback

### yesCallback

The callback will execute the function and returning boolean in input

## Example

In this example, We will put delay function to do `Log.write` message after 5 seconds.

### Steps

1. Drag a `button` component into the canvas and open the `Action` tab. Select the `press` event of the button and drag the `Control.delay` function to the event flow.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-1333be19fc8bf9b5caa7ab4295467086664dbf61%2Fdelay-step-1.png?alt=media)
2. Call the function `Control.delay`. Enter the parameters of the `Control.delay` function.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-15e69bf7c450ffdc51e8fc243d641b4c29c3c04f%2Fdelay-step-2.png?alt=media)
3. Put `Log.write` below the `Control.delay`. Then put the value as "Delaying!".

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-c4c09329f99d603d3ff9a0d504e12990da9a3daa%2Fdelay-step-3.png?alt=media)

### Result

1. The function will execute after 5 seconds. In this case to return "Delaying!".

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-20ca1a9a459e97ae9562d6170721eb9ed86aeb01%2Fdelay-result.png?alt=media)
