Skip to content
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

feat(injector): improve set method api #557

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/injector/src/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class Injector implements InjectorInterface {
throw new Error(`Invalid get<T> argument given ${token}`);
}

set<T>(token: T, value: any, scope?: Scope): void {
set(token: ContainerToken, value: any, scope?: Scope): void {
marcus-sa marked this conversation as resolved.
Show resolved Hide resolved
if (!this.setter) throw new Error('Injector was not built');
this.setter(token, value, scope);
}
Expand Down Expand Up @@ -915,7 +915,11 @@ export class InjectorContext {
}

set<T>(token: T, value: any, module?: InjectorModule): void {
return this.getInjector(module || this.rootModule).set(token, value, this.scope);
return this.getInjector(module || this.rootModule).set(
getContainerToken(token),
value,
this.scope,
);
}

static forProviders(providers: ProviderWithScope[]) {
Expand Down
Loading