Proxy Constants
const spec = {
get(o, key) {
return o[key] != null ?
o[key] : o[key] = Objector()
}
};
const Objector = () => new Proxy({}, spec);
const events = Objector();
events.graphics.RENDERED;
events.graphics.ERASED;
events.ui.LOADING;
events.ui.LOADED;
events.files.OPENED;
events.files.CLOSED;
const { ERASED } = events.graphics;
console.log('a', ERASED === events.graphics.ERASED);
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.