-
Notifications
You must be signed in to change notification settings - Fork 0
Interface On and off
ALexeyP0708 edited this page Jul 5, 2020
·
1 revision
At its core, an interface in debugged code is an Unnecessary option. Writing and using Interfaces is necessary when developing code. Therefore, this component is designed in such a way that Interfaces can be removed from code.
Exemples
// export_modules.js
// Interface Manager declaration
import {InterfaceManager} from './lib/Interfaces/InterfaceManager.js';
// Interface declaration
import {MyInterface} from './Interfaces/MyInterface.js';
import {MyInterface2} from './Interfaces/MyInterface2.js';
Object.assign(window,{MyInterface,MyInterface2});// global declaration in browsers
// work classes declaration
import {MyClass} from './core/MyClass.js';
import {MyClass2} from './core/MyClass2.js';
import {MyClass3} from './core/MyClass2.js';
// Interface Inheritance
InterfaceManager.expendInterfaces(MyClass,MyInterface);
InterfaceManager.freezePropСlass(MyClass,MyInterface2);
InterfaceManager.implementInterfaces(MyClass2,MyInterface2);
InterfaceManager.freezePropСlass(MyClass2);
InterfaceManager.implementInterfaces(MyClass3);
InterfaceManager.freezePropСlass(MyClass3);
// export classes.
Object.assign(window,{MyClass,MyClass2});// глобальное обьявление
export {MyClass,MyClass2};With direct inheritance of class interfaces MyClass extends MyInterface {}, you can exclude an interface class only by editing the code. In order not to edit the code, you can replace the interface with an empty class.
/* export_interfaces.js */
// productions
// export class MyInterface3 {}
// developers
import {MyInterface3} from './Interfaces/MyInterface.js';
export MyInterface3;
/* ./core/MyClass3.js */
import {MyInterface3} from '/export_interfaces.js';
class MyClass3 extends MyInterface3 {
}