duckengine
Version:
A 2D Game Engine for the web.
38 lines (37 loc) • 1.07 kB
TypeScript
/**
* @class Once
* @classdesc Creates a DuckEngine Once
* @description The Once Class. A tool that can run a function once even if it is in a loop
* @since 1.0.0
*/
export default class Once {
protected func: (...args: unknown[]) => unknown;
ran: boolean;
/**
* @constructor
* @description Creates a Once instance.
* @param {(...args: unknown[]) => unknown} func Function to run on Once.run
* @param {boolean} [run] Determines if function is run as soon as Once class is constructed
* @since 1.0.0
*/
constructor(func: (...args: unknown[]) => unknown, run?: boolean);
/**
* @memberof Once
* @description Runs the function once
* @since 1.0.0
*/
run(): void;
/**
* @memberof Once
* @description Resets the state and allows the function to be ran again if called
* @since 1.0.0
*/
reset(): void;
/**
* @memberof Once
* @description Sets the ran state
* @param {boolean} ran Ran state
* @since 1.0.0
*/
set state(ran: boolean);
}