siocc-tsdeprecated

Simple IOC Container for TypeScript

Usage no npm install needed!

<script type="module">
  import sioccTs from 'https://cdn.skypack.dev/siocc-ts';
</script>

README

SIOCC-TS

Simple IOC Container for TypeScript

This is an IOC container made specifically for TypeScript.

Usage

The simple instructions for installint the Simple IOC Container for TypeScript

  1. Install the npm-package.
    npm install siocc-ts --save-dev

  2. Include the TypeScript definition file in your solution.

  3. Add javascript file to your bundle using grunt, bower, etc.
    Keep in mind this is an ECMASCRIPT6 file so you will need babeljs if you don't want ECMASCRIPT6.
    Also this library uses strict javascript

  4. ...

  5. Profit

Example

You declare the application like this:

class Application extends ioc.ApplicationContext {
    constructor() {	super(); }

    public register(container: ioc.Container): void {
        // Register Instances
        container.registerSingleton<TypeName>(TypeName)
            .setInstantiateFunc(() => new instance(param...)) // (optional) Set an alternitive Instantiations function
            .setResolveFunc(instance => instance // (optional) Set a method to call directly after Resolve
                .someFunc()
                .addSomething(new Something()));

        this.initiate(container);
    }

    public initiate(container: ioc.Container): void {
      // App initiation logic here ---
    }
}

window.onload = () => new Application();

And you resolve instances like this:
ioc.Container.getCuttent().resolve(TypeName);

Contribute

Go to github.com/MarvinBrouwer/SIOCC-TS and clone the repo.

Credits

None yet.