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

37.5% Statements 3/8
0% Branches 0/2
20% Functions 1/5
37.5% Lines 3/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
    3x
    3x

    3x
    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();