Options
All
  • Public
  • Public/Protected
  • All
Menu

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);
     });
 }

Hierarchy

  • AtomOnce

Index

Methods

Methods

run

  • run(f: function): void
  • 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);
         });
     }

    Parameters

    • f: function
        • (): any
        • Returns any

    Returns void

Generated using TypeDoc