src/lib/EventBus.ts   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 28
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4
mnd 0
bc 0
fnc 4
bpm 0
cpm 1
noi 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A EventBus.off 0 3 1
A EventBus.once 0 3 1
A EventBus.on 0 3 1
A EventBus.emit 0 3 1
1
import EventEmitter2 from 'eventemitter2';
2
3
export default class EventBus {
4
    public emitter: EventEmitter2;
5
6
    constructor() {
7
        this.emitter = new EventEmitter2();
8
    }
9
10
    public on(event: string, listener: (...args: any[]) => void) {
11
        return this.emitter.on(event, listener);
12
    }
13
14
    public off(event: string, listener: (...args: any[]) => void) {
15
        return this.emitter.off(event, listener);
16
    }
17
18
    public emit(event: string, ...args: any[]) {
19
        return this.emitter.emit(event, ...args);
20
    }
21
22
    public once(event: string, listener: (...args: any[]) => void) {
23
        return this.emitter.once(event, listener);
24
    }
25
}
26
27
export const eventbus = new EventBus();
28