@rbxts/proton
Version:
Framework for Roblox game development
60 lines (59 loc) • 1.66 kB
TypeScript
/// <reference types="@rbxts/compiler-types" />
/**
* Provider decorator.
*/
export declare function Provider(): <T extends new () => InstanceType<T>>(providerClass: T) => void;
export declare namespace Proton {
/**
* Start Proton. This should only be called once per
* environment (e.g. once on the server and once on
* the client). Attempts to call this more than once
* will throw an error.
*
* If any providers yield within their constructors,
* then this method will also yield.
*
* ```ts
* Proton.start();
* print("Proton started");
* ```
*/
function start(): void;
/**
* Yields the calling thread until Proton has been
* fully started.
*
* ```ts
* Proton.awaitStart();
* print("Started");
* ```
*/
function awaitStart(): void;
/**
* Calls the callback once Proton has fully started.
* If Proton is already started, the callback will
* be spawned immediately.
* @param callback Callback
*/
function onStart(callback: () => void): void;
/**
* Gets a provider within Proton.
*
* An error will be thrown if the provider does not
* exist.
*
* ```ts
* // Directly
* const myProvider = Proton.get(MyProvider);
*
* // From another provider
* class AnotherProvider {
* private readonly myProvider = Proton.get(MyProvider);
* }
* ```
*
* @param providerClass The provider class
* @returns The provider singleton object
*/
function get<T extends new () => InstanceType<T>>(providerClass: T): InstanceType<T>;
}