InjectionSystem.js 456 B

123456789101112131415161718192021222324
  1. class InjectionSystem {
  2. constructor(){
  3. this.systems = {};
  4. }
  5. depend(SystemName, system) {
  6. if(this.systems[SystemName])
  7. return false;
  8. this.systems[SystemName] = system;
  9. return true;
  10. }
  11. inject(SystemName) {
  12. if(!this.systems[SystemName]) {
  13. console.warn("InjSys: A system was requested but not found: ", SystemName, new Error().stack);
  14. return false;
  15. }
  16. return this.systems[SystemName];
  17. }
  18. }
  19. export default new InjectionSystem();