Skip to main content

PromValue

A PromValue is a class that is used to store a value that may not be set yet. This is useful when you need to run something only after the value has been set atleast once.

Properties

ClassName

PromValue.ClassName: "PromValue"

The name of the class.

Changed

PromValue.Changed: Signal<any,any>

A signal that fires when the value of the PromValue changes.

Functions

new

Static
PromValue.new(
initialValueany?--

an optional initial value to set the PromValue to.

) → PromValue

Creates a new PromValue

Set

PromValue:Set(newValueany) → ()

Sets the value of the PromValue and fires the Changed signal.

Get

PromValue:Get() → ()

Immediately returns the stored value.

IsReady

PromValue:IsReady() → boolean

Returns whether or not the value has been set yet

OnReady

PromValue:OnReady(
fn((valueany) → ...any)?--

an optional function to call when the value is set.

) → Promise<any>

Returns a promise that resolves with the value when it has been set atleast once. If given a function then it will run it the first time it is set, this is equivalent to just chaining :andThen(). Alias for :Promise()

Promise

PromValue:Promise(
fn((valueany) → ...any)?--

an optional function to call when the value is set.

) → Promise<any>

Alias for :OnReady()

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new PromValue",
            "params": [
                {
                    "name": "initialValue",
                    "desc": "an optional initial value to set the PromValue to.",
                    "lua_type": "any?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PromValue"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 49,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "Set",
            "desc": "Sets the value of the PromValue and fires the Changed signal.",
            "params": [
                {
                    "name": "newValue",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 67,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "Get",
            "desc": "Immediately returns the stored value.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 78,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "IsReady",
            "desc": "Returns whether or not the value has been set yet",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 88,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "OnReady",
            "desc": "Returns a promise that resolves with the value when it has been set atleast once.\nIf given a function then it will run it the first time it is set, this is equivalent to just chaining :andThen().\nAlias for :Promise()",
            "params": [
                {
                    "name": "fn",
                    "desc": "an optional function to call when the value is set.",
                    "lua_type": "((value: any) -> ...any)?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<any>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 101,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "Promise",
            "desc": "Alias for :OnReady()",
            "params": [
                {
                    "name": "fn",
                    "desc": "an optional function to call when the value is set.",
                    "lua_type": "((value: any) -> ...any)?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<any>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 112,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "_peek",
            "desc": "This method allows for PromValues to be used with Fusion's peek function.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 120,
                "path": "src/promvalue/src/PromValue.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "ClassName",
            "desc": "The name of the class.",
            "lua_type": "\"PromValue\"",
            "source": {
                "line": 36,
                "path": "src/promvalue/src/PromValue.lua"
            }
        },
        {
            "name": "Changed",
            "desc": "A signal that fires when the value of the PromValue changes.",
            "lua_type": "Signal<any, any>",
            "source": {
                "line": 42,
                "path": "src/promvalue/src/PromValue.lua"
            }
        }
    ],
    "types": [],
    "name": "PromValue",
    "desc": "A PromValue is a class that is used to store a value that may not be set yet.\nThis is useful when you need to run something only after the value has been set atleast once.",
    "source": {
        "line": 9,
        "path": "src/promvalue/src/PromValue.lua"
    }
}