All files / decorators/gapi-effect gapi-effect.ts

25% Statements 4/16
100% Branches 0/0
0% Functions 0/3
25% Lines 4/16

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 207x 7x   7x 7x                              
import { ControllerContainerService } from '../../utils/services/controller-service/controller.service';
import Container from '../../utils/container/index';
import { GenericGapiResolversType } from '../../utils/services/controller-service/controller.service';
import { CacheService } from '../../utils/services/events/ngx-events-layer.service';
export function Effect(name: string): Function {
    const type = { effect:  name };
    Container.get(CacheService).getLayer<Array<any>>(name);
    return (t: any, propKey: string, descriptor: TypedPropertyDescriptor<any>) => {
        const self = t;
        const originalMethod = descriptor.value;
        const propertyKey = propKey;
        descriptor.value = function (...args: any[]) {
            const returnValue = originalMethod.apply(args);
            Object.assign(returnValue, type);
            return returnValue;
        };
        Container.get(ControllerContainerService).createController(self.constructor.name).setDescriptor(propertyKey, descriptor);
        return descriptor;
    };
}