Skip to content

Commit

Permalink
Added DI to README
Browse files Browse the repository at this point in the history
  • Loading branch information
patrimart committed Sep 18, 2016
1 parent 589d5a3 commit ec03d06
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Is a **TypeScript** library that contains may useful class decorators to help remove some of the tiresome boiler-plate from TypeScript/JavaScript development.
- **Jsonables** adds JSON Serialization/Deserialization to classes.
- **Decorators** wraps class members with convenient transformers, like **lodash** functions and others.
- **Dependency Injection** handles instantiation/destruction of class dependencies at the global and/or module level.


## Installation
Expand Down Expand Up @@ -63,6 +64,7 @@ assert.equals(myClass.getBar(), myNewClass.getBar());

Note: **Jsonables** offers highly customizable JSON serialization options beyond the basic example above. Explore the docs to learn more.


### Decorators - Wrap Class Members with Useful Transformers

The **Decorators** module provides many decorators to augment the input and output of class members. Most deocrators use the amazing **lodash** library. A few others provide features beyond what **lodash** offers.
Expand Down Expand Up @@ -100,6 +102,40 @@ class MyClass {
```


### Dependency Injection - Handle Class Dependencies


The **Dependency Injection** module provides an easy way to manage class dependencies. Dependencies are instantiated as Singletons that are sandboxed to the global or given module namespace.

**Example Dependency Injection Usage:**
```ts
@Injectable()
class Foo implements IInjectable {

public guid = Math.random().toString(36).substr(2);

public destruct(): void {
this.guid = null;
}
}

class MyClass implements IInjectable {

constructor (
@Inject(Foo) public foo: Foo
) {}

public destruct () {
this.foo = null;
}
}

const myClass = DI.Modularize<MyClass>(MyClass, "module.path");
console.log(myClass.foo);
DI.Destruct("module.path");
```


---

## Special Thanks
Expand Down

0 comments on commit ec03d06

Please sign in to comment.