Skip to content

Commit

Permalink
fix: factory support multiple value
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Dec 3, 2023
1 parent 69443de commit edaa25e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/injector.ts
Expand Up @@ -533,8 +533,7 @@ export class Injector {
const { creator, token } = ctx;

const value = applyHooks(creator.useFactory(this), token, this.hookStore);
creator.instance = new Set([value]);

creator.instance ? creator.instance.add(value) : (creator.instance = new Set([value]));
return value;
}
}
23 changes: 2 additions & 21 deletions test/injector.test.ts
@@ -1,23 +1,4 @@
import {
Autowired,
Injectable,
Injector,
INJECTOR_TOKEN,
Inject,
Optional,
Aspect,
Before,
After,
Around,
HookType,
IBeforeJoinPoint,
IAfterJoinPoint,
IAroundJoinPoint,
AfterReturning,
IAfterReturningJoinPoint,
AfterThrowing,
IAfterThrowingJoinPoint,
} from '../src';
import { Autowired, Injectable, Injector, INJECTOR_TOKEN, Inject, Optional } from '../src';
import * as InjectorError from '../src/error';
import { getInjectorOfInstance } from '../src/helper';

Expand Down Expand Up @@ -420,7 +401,7 @@ describe('test injector work', () => {
expect(injector1.id).not.toBe(injector2.id);
});

it('实例对象有 ID 数据', () => {
it('could get id from the instance', () => {
const injector = new Injector();
const instance1 = injector.get(A);
const instance2 = injector.get(A);
Expand Down

0 comments on commit edaa25e

Please sign in to comment.