All files / utils/services/controller-service controller-hooks.ts

50% Statements 4/8
0% Branches 0/2
40% Functions 2/5
50% Lines 4/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  8x 8x         4x                               8x
 
export class ControllerHooks {
    controllers: Map<string, any> = new Map();
 
    init() { }
 
    setHook(name: string, target: any) {
        this.controllers.set(name, target);
    }
 
    getHook(name) {
        if (this.hasHook(name)) {
            return this.controllers.get(name);
        } else {
            throw new Error('Hook not found!');
        }
    }
 
    hasHook(name: string) {
        return this.controllers.has(name);
    }
}
 
export const controllerHooks = new ControllerHooks();