Guys this is a feature I would love to see in the compiler (and support in linter if required and any other related projects). This would allow code like the following:
goog.require('namespace.*')
...
findHandlerForRequest(request) {
for (var clazz in namespace ) {
var handler = new clazz();
if (handler.supports(request) {
handler.run(request);
return;
}
}
throw new Error('Could not find a handler for request');
}
I don't know what this pattern is called (auto discovery??). Anyways, currently closure code always violates the open/closed principle because any client of an interface must always be aware of all implementations by having to explicitly define all goog.requires.
This to me sounds like a major enhancement so I put it here for discussion as its not a huge deal but it would be nice. I'm also a bit intimidated by the compiler code so since I wouldn't be implementing this I don't feel I have the right to add a proper enhancement request.
Any comments? Is this even possible with the current compiler/depsbuilder/linter design?