@aegenet/belt-anti-bounce
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

npm version

@aegenet/belt-anti-bounce

@antiBounce decorator

💾 Installation

yarn add @aegenet/belt-anti-bounce@^1.4.0
# or
npm i @aegenet/belt-anti-bounce@^1.4.0

📝 Usage

import { IAntiBounceSupport, IAntiBounce, disposeAntiBounces } from '@aegenet/belt-anti-bounce';

class Sample implements IAntiBounceSupport {
  public $antiBounces?: Map<string, IAntiBounce>;
  private _i = 0;

  @antiBounce({ duration: 300 })
  public inc(): void {
    this._i++;
  }

  public main() {
    this.inc();
    this.inc();
    this.inc();
    // this._i => 1
  }

  public dispose() {
    disposeAntiBounces(this);
  }
}

AntiBounce, utility

import { AntiBounce } from '@aegenet/belt-anti-bounce';

let i = 0;
const diposable = new AntiBounce(() => i++, 300);
assert.strictEqual(i, 0);
// Go !
diposable.call();
diposable.call();
diposable.call();
diposable.call();
// i = 0
await delay(300);
// i = 1

diposable.dispose();

Readme

Keywords

Package Sidebar

Install

npm i @aegenet/belt-anti-bounce

Weekly Downloads

2

Version

1.5.0

License

MIT

Unpacked Size

8.71 kB

Total Files

7

Last publish

Collaborators

  • agenet