Skip to main content

EncodedAttributeValue

Allows access to an attribute like a ValueObject, but also encoded or decoded

Functions

new

EncodedAttributeValue.new(
objectInstance,
attributeNamestring,
encode(TValue) → TEncoded,
decode(TEncoded) → TValue,
defaultValueTValue?
) → EncodedAttributeValue<TEncoded,TValue>

Constructs a new EncodedAttributeValue. If a defaultValue that is not nil is defined, then this value will be set on the Roblox object.

ObserveBrio

EncodedAttributeValue.ObserveBrio(
selfEncodedAttributeValue<TEncoded,TValue>,
condition((TEncoded) → boolean)?
) → Observable<Brio<TValue>>

Handles observing the value conditionally. The condition runs against the encoded attribute value, before it is decoded.

Observe

EncodedAttributeValue.Observe(selfEncodedAttributeValue<TEncoded,TValue>) → Observable<TValue>

Observes the decoded attribute on an instance, falling back to the default value whenever the attribute is not set.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new EncodedAttributeValue. If a defaultValue that is not nil\nis defined, then this value will be set on the Roblox object.",
            "params": [
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "encode",
                    "desc": "",
                    "lua_type": "(TValue) -> TEncoded"
                },
                {
                    "name": "decode",
                    "desc": "",
                    "lua_type": "(TEncoded) -> TValue"
                },
                {
                    "name": "defaultValue",
                    "desc": "",
                    "lua_type": "TValue?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "EncodedAttributeValue<TEncoded, TValue>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 67,
                "path": "src/attributeutils/src/Shared/EncodedAttributeValue.lua"
            }
        },
        {
            "name": "ObserveBrio",
            "desc": "Handles observing the value conditionally. The condition runs against the\nencoded attribute value, before it is decoded.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "EncodedAttributeValue<TEncoded, TValue>"
                },
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "((TEncoded) -> boolean)?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<TValue>>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 104,
                "path": "src/attributeutils/src/Shared/EncodedAttributeValue.lua"
            }
        },
        {
            "name": "Observe",
            "desc": "Observes the decoded attribute on an instance, falling back to the default\nvalue whenever the attribute is not set.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "EncodedAttributeValue<TEncoded, TValue>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<TValue>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 119,
                "path": "src/attributeutils/src/Shared/EncodedAttributeValue.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "EncodedAttributeValue",
    "desc": "Allows access to an attribute like a ValueObject, but also encoded or decoded",
    "source": {
        "line": 7,
        "path": "src/attributeutils/src/Shared/EncodedAttributeValue.lua"
    }
}