Skip to content

Instantly share code, notes, and snippets.

@justinfagnani
justinfagnani / gist:6aec137ed97cfa3db002
Last active August 29, 2015 14:22
Dependency Resolution with Events
Polymer({
is: 'x-foo',
ready() {
// provides a FooService to descendents
this.provideInstance('foo-service', new FooService());
},
attached() {
// requests a BarService from an ancestor, re-requests if moved
@calvinfroedge
calvinfroedge / dependencyresolver.php
Last active December 26, 2015 15:39
Dependency resolver I wired up that recursively injects dependencies at run time. Explanation and examples included!
<?php
/*
* Dependency injection can help you reduce coupling and increase testability, making your applications more maintainable.
*
* DependencyResolver gives you the best of both worlds by mixing a registry with call time dependency resolution. In addition, it provides significant resource
* usage advantages over other patterns, such as an object pool, because dependencies are only resolved when they are actually needed.
*
* It supports both constructor injection for class wide dependencies, as well as method injection for method specific dependencies.
*