Skip to content

Commit 8d7aef0

Browse files
committed
refactor: extract bindable interface for containers and modules
1 parent 82abd62 commit 8d7aef0

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/types.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type DependencyArray = DependencyKey[];
1010

1111
export type Scope = 'singleton' | 'transient' | 'scoped';
1212

13-
export interface Container {
13+
interface Bindable {
1414
bind(key: DependencyKey): {
1515
toValue: (value: unknown) => void;
1616
toFunction: (fn: CallableFunction) => void;
@@ -31,7 +31,9 @@ export interface Container {
3131
scope?: Scope
3232
) => void;
3333
};
34+
}
3435

36+
export interface Container extends Bindable {
3537
load(moduleKey: ModuleKey, module: Module): void;
3638

3739
get<T>(key: DependencyKey): T;
@@ -41,28 +43,7 @@ export interface Container {
4143
runInScope<T>(callback: () => T): T;
4244
}
4345

44-
export interface Module {
45-
bind(key: DependencyKey): {
46-
toValue: (value: unknown) => void;
47-
toFunction: (fn: CallableFunction) => void;
48-
toHigherOrderFunction: (
49-
fn: CallableFunction,
50-
dependencies?: DependencyArray | DependencyObject,
51-
scope?: Scope
52-
) => void;
53-
toCurry: (
54-
fn: CallableFunction,
55-
dependencies?: DependencyArray | DependencyObject,
56-
scope?: Scope
57-
) => void;
58-
toFactory: (factory: CallableFunction, scope?: Scope) => void;
59-
toClass: <C>(
60-
constructor: new (...args: any[]) => C,
61-
dependencies?: DependencyArray | DependencyObject,
62-
scope?: Scope
63-
) => void;
64-
};
65-
46+
export interface Module extends Bindable {
6647
bindings: Map<DependencyKey, Binding>;
6748
}
6849

0 commit comments

Comments
 (0)