4.0.2 • Published 3 months ago

adain-simple-event v4.0.2

Weekly downloads
17
License
MIT
Repository
github
Last release
3 months ago

adain-simple-event

Install

npm install --save adain-simple-event

Usage

import SimpleEvent from "adain-simple-event";

const MY_EVENT_TYPE = 'MyEvent';
let callback = function(data){
  console.log(data);  // {msg: 'HI'}
};
let eventId = SimpleEvent.register(MY_EVENT_TYPE, callback);
SimpleEvent.dispatch(type, {msg: 'HI'});

// unregister
SimpleEvent.unRegister(eventId);

// register with context
eventId = SimpleEvent.register(MY_EVENT_TYPE, callback, this);

let eventIds = [];
eventIds.push(SimpleEvent.register(MY_EVENT_TYPE, callback));
eventIds.push(SimpleEvent.register(MY_EVENT_TYPE, callback));
eventIds.push(SimpleEvent.register(MY_EVENT_TYPE, callback));

// unregister with id array
SimpleEvent.unRegisterWithArr(eventIds);
eventIds = null;

// debug mode
SimpleEvent.isDebug = true;

// change warning count
SimpleEvent.warningCount = 10;  // default is 5

License

MIT

4.0.2

3 months ago

4.0.0

2 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.0.6

4 years ago

2.0.3

5 years ago

2.0.1

5 years ago

2.0.2

5 years ago

2.0.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

7 years ago

1.0.0

7 years ago