Releases: mattias800/diskajs
Releases · mattias800/diskajs
Removed .babelrc
.babelrc used to build diska is no longer included in distributed package.
Added default injector
- Bug fix
- New way of creating instances which doesn't create an intermediary object of type Temp. Types are now correct in all ways.
- Added defaultInjector which is empty, and can be used when not needing to bind any types explicitly in a module.
import { defaultInjector } from "diskajs";
import MySweetClass from "./MySweetClass";
let obj = defaultInjector.get(MySweetClass);
Added support for injecting the injector
If you for some reason need the injector to manually get instances (for example for conditional instantiation), you can now inject it just like any other object.
import {Inject, Injector, Singleton} from "diskajs";
@Inject(Injector)
@Singleton()
export default class ClassWithInjector {
injector:Injector;
constructor(injector:Injector) {
this.injector = injector;
}
}
Support for ES7 decorators
Major feature
Decorators
This release adds support for decorators.
@Inject(..)
@singleton()
Add @Inject() decoration to any class that is instantiated by diska. Add types to be injected as parameters.
Add @singleton() and there will only be one instance created by that injector.
See documentation for more information.
Breaking changes
Constructor argument name based injection is no longer supported.
Previously, diska could look up a type based on argument name. From now on, you must use @Inject() or add static inject() method to class.