mirror of
https://github.com/morten-olsen/react-native-debug-console.git
synced 2026-02-08 00:36:26 +01:00
22 lines
325 B
JavaScript
22 lines
325 B
JavaScript
class Events {
|
|
constructor() {
|
|
this.listeners = [];
|
|
}
|
|
|
|
listen(fn) {
|
|
this.listeners.push(fn);
|
|
}
|
|
|
|
unlisten(fn) {
|
|
this.listeners = this.listeners.filter(l => l !== fn);
|
|
}
|
|
|
|
publish(type, data) {
|
|
this.listeners.forEach(l => l(type, data));
|
|
}
|
|
}
|
|
|
|
const events = new Events();
|
|
|
|
export default events;
|