samchon/tstl

Implement `VariadicSingleton` and `VariadicMutableSingleton`

samchon opened this issue · 0 comments

Implement variadic singleton classes.

export class VariadicSingleton<T, Args extends any[]>
{
    public constructor
        (
            closure: (...args: Args) => T),
            hashFunc?: (args: Args) => number,
            pred?: (x: Args, y: Args) => boolean
        );
    public get(...args: Args[]): T;
}

export class VariadicMutableSingleton<T, Args extends any[]>
{
    public constructor
        (
            closure: (...args: Args) => Promise<T>,
            hashFunc?: (args: Args) => number,
            pred?: (x: Args, y: Args) => boolean
        );
    public set(...items: [...Args, T]): Promise<void>;
    public reload(...args: Args): Promise<T>;

    public get(...args: Args): Promise<T>;
    public is_loaded(...args: Args): Promise<boolean>;
}