An open API service indexing awesome lists of open source software.

https://github.com/gregonnet/typescript-playground

A place where I can get deeper into the typescript language
https://github.com/gregonnet/typescript-playground

Last synced: 10 months ago
JSON representation

A place where I can get deeper into the typescript language

Awesome Lists containing this project

README

          

## 5 - Dependency resolution

Using external modules you can register classes giving them a `name`.

```ts

import IoC = require('../core/IoC');
import Resolvable = require('../core/Resolvable');

// Class you want to register
import ClassA = require('./ClassA');

// Using the Interface to resolve the registered class
import InterfaceA = require('./InterfaceA');

// Create an instance of the class
var classA = new ClassA('http://google.de');

var ioc = new IoC();
ioc.register(new Resolvable('classA', classA));

var resolved = ioc.resolve('classA');
resolved.greet();

```