Added once() method

This commit is contained in:
2023-12-18 22:28:48 +02:00
parent f46565f5c2
commit 331ddab544
4 changed files with 24 additions and 5 deletions

View File

@ -128,6 +128,8 @@ export class UserAPI {
public MidiConnection: MidiConnection;
public scale_aid: string | number | undefined = undefined;
public hydra: any;
public onceEvaluator: boolean = true;
load: samples;
constructor(public app: Editor) {
@ -912,6 +914,18 @@ export class UserAPI {
// Counter and iteration
// =============================================================
public once = (): boolean => {
/**
* Returns true if the code is being evaluated for the first time.
*
* @returns True if the code is being evaluated for the first time
*/
const firstTime = this.app.api.onceEvaluator;
this.app.api.onceEvaluator = false;
return firstTime;
}
public counter = (
name: string | number,
limit?: number,