-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
injector hierarchy #13
Comments
Also, take a look at the API of |
Hi Minko,
thank you for your feedback!
I read your article and knew already the angular Reflector-Api.
My issues were around unit testing and initialization.
Due to wrong asumptions I did not setup di correctly in my unit tests.
Now all is fine and works like expected:
@Injectable()
@FlxComponent({
})
export class CoreBootstrapComponent {
constructor(public logger: Logger) {
}
public log(message: string) {
this.logger.log(message);
}
}
@FlxModule({
imports: [
],
declarations: [
CoreBootstrapComponent
],
exports: [
CoreBootstrapComponent
],
providers: [
Logger
],
bootstrap: CoreBootstrapComponent
})
export class CoreBootstrapModule {
constructor(public injector: Injector) {
// tslint:disable-next-line:no-console
console.log(`injector: ` + injector);
this.injector = injector;
}
}
rootInjector = ModuleMetadataStorage.instance.bootstrapModule(CoreBootstrapModule);
regards,
Walter
Von: Minko Gechev<mailto:notifications@github.com>
Gesendet: Montag, 10. Juli 2017 18:29
An: mgechev/injection-js<mailto:injection-js@noreply.github.com>
Cc: Walter Leinert<mailto:walter.leinert@outlook.com>; Author<mailto:author@noreply.github.com>
Betreff: Re: [mgechev/injection-js] injector hierarchy (#13)
This might be helpful<http://blog.mgechev.com/2017/01/30/implementing-dependency-injection-react-angular-element-injectors/>.
Also, take a look at the API of ReflectiveInjector<https://angular.io/api/core/ReflectiveInjector>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#13 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALKjZ3wFnXtL0rrmngUR3NSrWu2nYvIGks5sMlFDgaJpZM4OTEbr>.
|
I am happy you solved the issue. The |
I thought the @Injectable decorator would also set some metainfo for di; or is it only not neccessary in this context?
Von: Minko Gechev<mailto:notifications@github.com>
Gesendet: Dienstag, 11. Juli 2017 12:50
An: mgechev/injection-js<mailto:injection-js@noreply.github.com>
Cc: Walter Leinert<mailto:walter.leinert@outlook.com>; Author<mailto:author@noreply.github.com>
Betreff: Re: [mgechev/injection-js] injector hierarchy (#13)
I am happy you solved the issue. The @Injectable decorator in the first class declaration in not necessary since you already have another decorator applied.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#13 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALKjZ1bYgI5NDI4ubbgvJ0vAe-9Im3boks5sM1NegaJpZM4OTEbr>.
|
It doesn't do anything, since the declaration metadata generation is already triggered by |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Minko,
I'm implementing a framework for efficiently creating modern web apps based on angular (2), express and knex. For the angular part I'm using angular DI, for the express part I'm using ts-express-decorators DI.
For the part which is client/server independent I started to use injection-js because it's compatible with angular and really powerful. Now I'm implementing decorator based modules and components like in angular, but have some trouble with creating the injector hierarchy.
Like in angular I experiment with bootstrapping my root module with a root component and providers.
What is the right way to setup and link hierarchical injectors? When to use ReflectiveInjector.resolveAndCreate()/createChildFromResolved() or something like this?
Is it possible to reset your library (global state) to some initial state for unit testing and testing the bootstrapping in various tests?
Regards,
Walter
The text was updated successfully, but these errors were encountered: