@rbxts/planck-flamecs-hooks
Version:
A @rbxts/planck plugin that provides support for @rbxts/flamecs hooks.
31 lines (30 loc) • 1.21 kB
TypeScript
import type { Modding } from "@flamework/core";
type Callback<T extends Array<unknown>> = (...args: T) => void;
type EventLike<T extends Array<unknown> = Array<unknown>> = ((callback: Callback<T>) => ConnectionLike) | {
Connect(callback: Callback<T>): ConnectionLike;
} | {
connect(callback: Callback<T>): ConnectionLike;
} | {
on(callback: Callback<T>): ConnectionLike;
};
type ConnectionLike = (() => void) | {
Disconnect(): void;
} | {
disconnect(): void;
};
/**
* Utility for handling event-like objects.
*
* Connects to the provided event-like object and stores incoming events.
* Returns an iterable function that yields the stored events in the order they
* were received.
*
* @template T - The tuple type of event arguments.
* @param event - The event-like object to connect to.
* @param discriminator - An optional value to additionally key by.
* @param key - An automatically generated key to store the event state.
* @returns An iterable function that yields stored events.
* @metadata macro
*/
export declare function useEvent<T extends Array<unknown>>(event: EventLike<T>, discriminator?: unknown, key?: Modding.Caller<"uuid">): IterableFunction<T>;
export {};