Skip to main content

PromiseUtils

Utility methods for promise

Functions

any

PromiseUtils.any(promises{Promise<T>}) → Promise<T>--

Promise that resolves with first result

Returns the value of the first promise resolved

delayed

PromiseUtils.delayed(secondsnumber) → Promise

Returns a promise that will resolve after the set amount of seconds

all

PromiseUtils.all(promises{Promise<T>}) → Promise<T>

Executes all promises. If any fails, the result will be rejected. However, it yields until every promise is complete.

warning

Passing in a spare array (i.e. {nil, promise}) will result in undefined behavior here.

combine

PromiseUtils.combine(stateTableany) → Promise<any>

Combines the result of promises together

invert

PromiseUtils.invert(promisePromise<T>) → Promise<T>

Inverts the result of a promise, turning a resolved promise into a rejected one, and a rejected one into a resolved one.

fromSignal

PromiseUtils.fromSignal(signalSignal<T>) → Promise<T>

Creates a promise from a signal

timeout

PromiseUtils.timeout(
timeoutTimenumber,
fromPromisePromise<T>
) → Promise<T>

Creates a new promise from the given promise that will reject after the given timeoutTime

Show raw api
{
    "functions": [
        {
            "name": "any",
            "desc": "Returns the value of the first promise resolved",
            "params": [
                {
                    "name": "promises",
                    "desc": "",
                    "lua_type": "{ Promise<T> }"
                }
            ],
            "returns": [
                {
                    "desc": "Promise that resolves with first result",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 17,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        },
        {
            "name": "delayed",
            "desc": "Returns a promise that will resolve after the set amount of seconds",
            "params": [
                {
                    "name": "seconds",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 41,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        },
        {
            "name": "all",
            "desc": "Executes all promises. If any fails, the result will be rejected. However, it yields until\nevery promise is complete.\n\n:::warning\nPassing in a spare array (i.e. {nil, promise}) will result in undefined behavior here.\n:::",
            "params": [
                {
                    "name": "promises",
                    "desc": "",
                    "lua_type": "{ Promise<T> }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 60,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        },
        {
            "name": "combine",
            "desc": "Combines the result of promises together",
            "params": [
                {
                    "name": "stateTable",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<any>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 97,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        },
        {
            "name": "invert",
            "desc": "Inverts the result of a promise, turning a resolved promise\ninto a rejected one, and a rejected one into a resolved one.",
            "params": [
                {
                    "name": "promise",
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 147,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        },
        {
            "name": "fromSignal",
            "desc": "Creates a promise from a signal",
            "params": [
                {
                    "name": "signal",
                    "desc": "",
                    "lua_type": "Signal<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 170,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        },
        {
            "name": "timeout",
            "desc": "Creates a new promise from the given promise that will\nreject after the given `timeoutTime`",
            "params": [
                {
                    "name": "timeoutTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "fromPromise",
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 194,
                "path": "src/promise/src/Shared/PromiseUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PromiseUtils",
    "desc": "Utility methods for promise",
    "source": {
        "line": 5,
        "path": "src/promise/src/Shared/PromiseUtils.lua"
    }
}