Skip to main content

Root

Entry point for rendering Dex applications.

In order to write a Dex application, you need to first create a root via Dex.Root, and render an instance using Root:Render()

-- Create our Dex application
local App = Dex.Premade("ScreenGui", {}, {
    Label = Dex.Premade("TextLabel", {
        Text = "Hello, World!",
    })
})

-- Render our Dex app over a premade ScreenGui template named "App"
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local root = Dex.Root(PlayerGui:WaitForChild("App"))
root.Render(App)

Constructor


Dex.Root

Dex.Root(hostInstance: Instance) -> Root

Creates a new Root instance. The Root is a reference to a real Roblox Instance and can render VirtualInstances using Root:Render.

Functions

Render

Root:Render(nodeVirtualInstance) → ReconciledNode

Reconciles a Virtual Instance into the root's Roblox Instance. After the call, the Virtual Instance is sealed and cannot be mutated. Instead, you should use Dex Observers to mutate the Instance after reconciliation.

It returns the Reconciled Node.

Unmount

Root:Unmount() → ()

Unmounts the Virtual Instance from the Root, causing it to be deleted from the DataModel.

Destroy

Root:Destroy() → ()

Unmounts and destroys the Root and its underlying Roblox Instance. This function should be called before discarding a Root object to ensure memory is properly freed.

Show raw api
{
    "functions": [
        {
            "name": "Render",
            "desc": "Reconciles a Virtual Instance into the root's Roblox Instance. After the\ncall, the Virtual Instance is sealed and cannot be mutated. Instead, you\nshould use Dex Observers to mutate the Instance after reconciliation.\n\nIt returns the Reconciled Node.",
            "params": [
                {
                    "name": "node",
                    "desc": "",
                    "lua_type": "VirtualInstance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ReconciledNode"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 64,
                "path": "src/Reconciler/Root.luau"
            }
        },
        {
            "name": "Unmount",
            "desc": "Unmounts the Virtual Instance from the Root, causing it to be deleted from\nthe DataModel.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 83,
                "path": "src/Reconciler/Root.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Unmounts and destroys the Root and its underlying Roblox Instance. This\nfunction should be called before discarding a Root object to ensure memory\nis properly freed.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 97,
                "path": "src/Reconciler/Root.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Root",
    "desc": "Entry point for rendering Dex applications.\n\nIn order to write a Dex application, you need to first create a root via\n[Dex.Root], and render an instance using [Root:Render()]\n\n```lua\n-- Create our Dex application\nlocal App = Dex.Premade(\"ScreenGui\", {}, {\n    Label = Dex.Premade(\"TextLabel\", {\n        Text = \"Hello, World!\",\n    })\n})\n\n-- Render our Dex app over a premade ScreenGui template named \"App\"\nlocal PlayerGui = game.Players.LocalPlayer:WaitForChild(\"PlayerGui\")\nlocal root = Dex.Root(PlayerGui:WaitForChild(\"App\"))\nroot.Render(App)\n```\n\n## Constructor\n\n---\n\n### Dex.Root\n\n```lua\nDex.Root(hostInstance: Instance) -> Root\n```\n\nCreates a new [Root] instance. The Root is a reference to a real Roblox\nInstance and can render VirtualInstances using [Root:Render].",
    "source": {
        "line": 48,
        "path": "src/Reconciler/Root.luau"
    }
}