Skip to content

Idea Backlog

Remo H. Jansen edited this page May 16, 2016 · 16 revisions

Here you can find some ideas that might be implemented in the future:

let kernel = new Kernel();
kernel.applyCacheProvider();
kernel.bind<T>("T").to(T).withCache({ stdTTL: 100, checkperiod: 120 });

Consider the following object composition:

interface IKatanaBlade {}
class KatanaBlade implements IKatanaBlade {}

interface IKatanaHandler {}
class KatanaHandler implements IKatanaHandler {}

@injectable("IKatanaHandler", "IKatanaBlade")
@paramNames("handler", "blade")
class Katana implements IWeapon {

    public handler: IKatanaHandler;
    public blade: IKatanaBlade;
    
    public constructor(handler: IKatanaHandler, blade: IKatanaBlade) {
        this.handler = handler;
        this.blade = blade;
    }
}

interface IWeapon {}
class Shuriken implements IWeapon {}

interface INinja {
    primary: IWeapon;
    secondary: IWeapon;
}

@injectable("IWeapon", "IWeapon")
@paramNames("primary", "secondary")
class Ninja implements INinja {

    public primary: IWeapon;
    public secondary: IWeapon;
    
    public constructor(@tagged("throwable", false) primary: IWeapon, @tagged("throwable", true) primary: IWeapon) {
        this.katana = katana;
        this.shuriken = secondary;
    }
}

The contextLogger will display something like the following in console when INinja is resolved:

└── plan
    ├── parentContext
    └── rootRequest
        ├── service: "INinja"
        ├── bindings: [{ runtimeIdentifier: Ninja }]
        ├── target: null
        └── childRequests
            ├── 0
               ├── service: "IWeapon"
               ├── bindings: [{ runtimeIdentifier: Katana }]├── target: { service: "IWeapon", name: "primary", metadata: [{ key: "throwable", value: false }] }
               └── childRequests
               ├── 0
                  ├── service: "IKatanaHandler"
                  ├── bindings: [{ runtimeIdentifier: KatanaHandler }]
                  ├── target: { service: "IKatanaHandler", name: "handler", metadata: [] }
                  └── childRequests: []
               └── 1├── service: "IKatanaBlade"├── bindings: [{ runtimeIdentifier: KatanaBlade }]├── target: { service: "IKatanaBlade", name: "blade", metadata: [] }
                   └── childRequests: []
            └── 1
                ├── service: "IWeapon"
                ├── bindings: [{ runtimeIdentifier: Shuriken }]
                ├── target: { service: "IWeapon", name: "secondary", metadata: [{ key: "throwable", value: true }] }
                └── childRequests: []

It should also include a simplified version:

└── plan
    └── "INinja" => Ninja
        ├── "IWeapon" => Katana
           ├── "IKatanaHandler" => KatanaHandler
           └── "IKatanaBalde" => KatanaBlade
        └── "IWeapon" => Shuriken
Clone this wiki locally