)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

Proxy Constants

  1. const spec = {
  2.   get(o, key) { 
  3.     return o[key] != null ? 
  4.       o[key] : o[key] = Objector()
  5.   }
  6. };
  7.  
  8. const Objector = () => new Proxy({}, spec);
  9.  
  10. const events = Objector();
  11.  
  12. events.graphics.RENDERED;
  13. events.graphics.ERASED;
  14. events.ui.LOADING;
  15. events.ui.LOADED;
  16. events.files.OPENED;
  17. events.files.CLOSED;
  18.  
  19. const { ERASED } = events.graphics;
  20. console.log('a', ERASED === events.graphics.ERASED);
  21. console.log('b', ERASED === events.files.CLOSED);

This is somewhat evil… I’ve never liked these java style constants. Maybe I’ll write up a detailed alternative method some time.

// humor // proxies // tricks
snippet.zone ~ 2021-24 /// {s/z}