The API consists in three methods:
register<T>(idOrInstance: string | any, instance?: any): void: Register instance with given identifier. The instance registered will be available for
inject(id: any): A decorator to inject a previously registered instance into target class property. (see usage below)
resolve<T>(id: any): T: Get previously registered instance by given name or type. (used under the hood by
Your compiler/transpiler need to understand the decorator
in order to be able to use
injectd. Here's how you enable it using:
// application.ts// screen.ts// main.ts;// anywhere.ts;screen.app // your "Application" instance is here!