UNPKG

@web-atoms/core

Version:
41 lines 1.34 kB
/** * AtomOnce will execute given method only once and it will prevent recursive calls. * This is important when you want to update source and destination and prevent recursive calls. * @example * private valueOnce: AtomOnce = new AtomOnce(); * * private onValueChanged(): void { * valueOnce.run(()=> { * this.value = compute(this.target); * }); * } * * private onTargetChanged(): void { * valueOnce.run(() => { * this.target = computeInverse(this.value); * }); * } */ export declare class AtomOnce { private isRunning; /** * AtomOnce will execute given method only once and it will prevent recursive calls. * This is important when you want to update source and destination and prevent recursive calls. * @example * private valueOnce: AtomOnce = new AtomOnce(); * * private onValueChanged(): void { * valueOnce.run(()=> { * this.value = compute(this.target); * }); * } * * private onTargetChanged(): void { * valueOnce.run(() => { * this.target = computeInverse(this.value); * }); * } */ run(f: () => any): void; } //# sourceMappingURL=AtomOnce.d.ts.map