Voilà, Dependency Injection
A dependency injection library for async utility, modularity, and testability
Create the dependency injection container
; const container = ;
Configure a dependency graph and get values
; { return <any> ;} const container = ; // It will lazily resolve only the transitive dependencies of the requested keycontainer;// => e done before b// => 13 // Or it can eagerly load the entire graph,// Note: will only eagerly load if container.then or container.catch is calledconst values = await container;console;// => { d: 5, e: undefined, b: 2, c: 5, f: 6, a: 13 }
Configure a dependency graph and ensure all the tasks are triggered once
; { return { ; };} const container2 = ; container2;// => c done// => b done after c// => a done after b and c// => { d: 5, e: 6, c: undefined, b: undefined, a: undefined }
Resolve a graph with resolvable circular dependencies
; const container = ; const a b c = await container;console;// => a: 3, b: 4, c: 2
Inspect a tree view of all of the dependencies in the graph using topiary
to pretty print the tree
;; const container3 = ; const tree = container3;const treeView = ;console; // container// ├─┬service1// │ ├─┬service2// │ │ └──service3// │ └──service3// ├─┬service2// │ └──service3// └──service3