1.0.0 • Published 2 years ago

@rbxts/experimental-reflect v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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."