@gogrillion/on-off
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

On-Off

Basic event implementation with fast performance.

Documentation

On-Off provides a base class OnOff with on, off, and fire methods.

Installation

Include as a

npm install @gogrillion/on-off --save

Basic Usage

Typescript Example

import {OnOff} from './index'

class ObjectWithEvents extends OnOff {
  
  constructor(){
    super();
  }
  
  downloadImage(){
    setTimeout(() => this.fire('image-loaded'), 1000 );
  }
  
}

let evObj = new ObjectWithEvents();
evObj.on('image-loaded', () => console.log('Image has downloaded') );
evObj.downloadImage();

// console will print 'Image has downloaded' in 1 sec.

Development

Run npm run compile to generate js files from typescript sources.

License / Credits

Under ISC License

Readme

Keywords

Package Sidebar

Install

npm i @gogrillion/on-off

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

7.92 kB

Total Files

8

Last publish

Collaborators

  • gogrillion