Skip to main content

Flag

Represents an individual flag.

This provides convenience access to other library functions with this flag already provided. See FeatureFlags for more information about each function.

Properties

name

This item is read only and cannot be modified. Read Only
Flag.name: string

The name of this flag.

Functions

create

Flag.create(configPartialFlagConfig) → ()

Creates a new flag with the provided configuration.

caution

Receiving a Flag object generally indicates that a flag already exists. The create function should only be used to create flags that don't already exist.

See: create

Errors

TypeDescription
"Flag '%s' already exists."Thrown when a flag with this name already exists.

exists

Flag.exists() → boolean

Checks if this flag currently exists.

See: exists

read

Flag.read() → FlagConfig

Reads the data of this flag.

See: read

update

Flag.update(configPartialFlagConfig) → ()

Updates the configuration of this flag.

See: update

retire

Flag.retire(retired?boolean) → ()

Sets the retired status of this flag.

See: retire

destroy

Flag.destroy() → ()

Removes this flag entirely.

See: destroy

isActive

Flag.isActive(
context?ActivationContext,
) → boolean

Checks if a feature flag is active based on provided context and configuration.

See: isActive

onChange

Flag.onChange(callback(recordChangeRecord) → ()) → Connection

Subscribe to the changed event for this flag.

This callback is only invoked when this flag is changed.

See: Changed

Show raw api
{
    "functions": [
        {
            "name": "create",
            "desc": "Creates a new flag with the provided configuration.\n\n:::caution\nReceiving a Flag object generally indicates that a flag already exists. The\n`create` function should only be used to create flags that don't already\nexist.\n:::\n\nSee: [create](FeatureFlags#create)",
            "params": [
                {
                    "name": "config",
                    "desc": "",
                    "lua_type": "PartialFlagConfig"
                }
            ],
            "returns": [],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"Flag '%s' already exists.\"",
                    "desc": "Thrown when a flag with this name already exists."
                }
            ],
            "source": {
                "line": 54,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "exists",
            "desc": "Checks if this flag currently exists.\n\nSee: [exists](FeatureFlags#exists)",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "read",
            "desc": "Reads the data of this flag.\n\nSee: [read](FeatureFlags#read)",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "FlagConfig"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 76,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "update",
            "desc": "Updates the configuration of this flag.\n\nSee: [update](FeatureFlags#update)",
            "params": [
                {
                    "name": "config",
                    "desc": "",
                    "lua_type": "PartialFlagConfig"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 87,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "retire",
            "desc": "Sets the retired status of this flag.\n\nSee: [retire](FeatureFlags#retire)",
            "params": [
                {
                    "name": "retired?",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 98,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "destroy",
            "desc": "Removes this flag entirely.\n\nSee: [destroy](FeatureFlags#destroy)",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 107,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "isActive",
            "desc": "Checks if a feature flag is active based on provided context and\nconfiguration.\n\nSee: [isActive](FeatureFlags#isActive)",
            "params": [
                {
                    "name": "context?",
                    "desc": "",
                    "lua_type": "ActivationContext"
                },
                {
                    "name": "config?",
                    "desc": "",
                    "lua_type": "ActivationConfig"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 122,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "onChange",
            "desc": "Subscribe to the changed event for this flag.\n\nThis callback is only invoked when this flag is changed.\n\nSee: [Changed](FeatureFlags#Changed)",
            "params": [
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "(record: ChangeRecord) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Connection"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 137,
                "path": "lib/createFlag.lua"
            }
        },
        {
            "name": "createFlag",
            "desc": "Creates a new flag object.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Flag\n"
                }
            ],
            "function_type": "static",
            "ignore": true,
            "source": {
                "line": 144,
                "path": "lib/createFlag.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "name",
            "desc": "The name of this flag.",
            "lua_type": "string",
            "readonly": true,
            "source": {
                "line": 35,
                "path": "lib/createFlag.lua"
            }
        }
    ],
    "types": [],
    "name": "Flag",
    "desc": "Represents an individual flag.\n\nThis provides convenience access to other library functions with this flag\nalready provided. See [FeatureFlags] for more information about each function.",
    "source": {
        "line": 14,
        "path": "lib/createFlag.lua"
    }
}