Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 981 Bytes

README.md

File metadata and controls

35 lines (24 loc) · 981 Bytes

Experimental Reflect

An experimental and incomplete Roblox-TS implementation of the Reflect Metadata API.

Declarative Syntax:

import { Reflect } from "@rbxts/experimental-reflect"

class MyClass {
    @Reflect.metadata("custom:MyMetadata", "This is the metadata for MyProperty.")
    public MyProperty = "Hello, world!"
}

const MyClassInstance = new MyClass()

print(Reflect.getMetadata("custom:MyMetadata", MyClassInstance, "MyProperty")) // Expected output: "This is the metadata for MyProperty."

Imperative Syntax:

import { Reflect } from "@rbxts/experimental-reflect"

class MyClass {
    public MyProperty = "Hello, world!"

    public constructor() {
        Reflect.defineMetadata("custom:MyMetadata", "This is the metadata for MyProperty.", this, "MyProperty")
    }
}

const MyClassInstance = new MyClass()

print(Reflect.getMetadata("custom:MyMetadata", MyClassInstance, "MyProperty")) // Expected output: "This is the metadata for MyProperty."