All files / decorators/gapi-controller gapi-controller.decorator.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 427x                                                                                  
import 'reflect-metadata';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { ControllerContainerService } from '../../utils/services/controller-service/controller.service';
import { ControllerMappingSettings, GenericGapiResolversType } from '../../utils/services/controller-service/controller.service';
import Container from '../../utils/container/index';
 
// export interface GapiController {
//     _controller_name: string;
//     _settings: ControllerMappingSettings;
//     _queries: Map<string, GenericGapiResolversType>;
//     _subscriptions: Map<string, GenericGapiResolversType>;
//     _mutations: Map<string, GenericGapiResolversType>;
// }
 
// export function GapiController<T, K extends keyof T>(settings?: ControllerMappingSettings) {
//     const options = settings;
//     return (target) => {
//         const original = target;
//         const currentController = Container.get(ControllerContainerService).createController(original.prototype.name);
//         function construct(constructor, args) {
//             const c: any = function () {
//                 this.gapi_settings  = currentController._settings;
//                 this.gapi_mutations = currentController._mutations;
//                 this.gapi_queries = currentController._queries;
//                 this.gapi_subscriptions = currentController._subscriptions;
//                 if(options) {
//                     Object.assign(this.gapi_settings, options)
//                 }
//                 return constructor.apply(this, args);
//             };
//             c.prototype = constructor.prototype;
//             Container.set({type: c});
//             return new c();
//         }
//         const f: any = function (...args) {
//             console.log('Loaded Controller: ' + original.name);
//             return construct(original, args);
//         };
//         return f;
//     };
// }