Skip to content

Commit 29b56ce

Browse files
committed
cleanup(di): make DependencyProvider private
1 parent 820b30c commit 29b56ce

File tree

3 files changed

+14
-33
lines changed

3 files changed

+14
-33
lines changed

modules/angular2/src/core/di/injector.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ export class BindingWithVisibility {
387387
}
388388

389389
/**
390+
* @private
390391
* Used to provide dependencies that cannot be easily expressed as bindings.
391392
*/
392393
export interface DependencyProvider {
@@ -469,9 +470,6 @@ export class Injector {
469470
* The passed-in bindings can be an array of `Type`, {@link Binding},
470471
* or a recursive array of more bindings.
471472
*
472-
* The method also takes an optional {@link DependencyProvider}, which is used to
473-
* resolve dependencies that cannot be expressed as bindings.
474-
*
475473
* ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
476474
*
477475
* ```typescript
@@ -492,20 +490,16 @@ export class Injector {
492490
* because it needs to resolve the passed-in bindings first.
493491
* See {@link resolve} and {@link fromResolvedBindings}.
494492
*/
495-
static resolveAndCreate(bindings: Array<Type | Binding | any[]>,
496-
depProvider: DependencyProvider = null): Injector {
493+
static resolveAndCreate(bindings: Array<Type | Binding | any[]>): Injector {
497494
var resolvedBindings = Injector.resolve(bindings);
498-
return Injector.fromResolvedBindings(resolvedBindings, depProvider);
495+
return Injector.fromResolvedBindings(resolvedBindings);
499496
}
500497

501498
/**
502499
* Creates an injector from previously resolved bindings.
503500
*
504501
* This API is the recommended way to construct injectors in performance-sensitive parts.
505502
*
506-
* The method also takes an optional {@link DependencyProvider}, which is used to
507-
* resolve dependencies that cannot be expressed as bindings.
508-
*
509503
* ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
510504
*
511505
* ```typescript
@@ -523,12 +517,10 @@ export class Injector {
523517
* expect(injector.get(Car) instanceof Car).toBe(true);
524518
* ```
525519
*/
526-
static fromResolvedBindings(bindings: ResolvedBinding[],
527-
depProvider: DependencyProvider = null): Injector {
520+
static fromResolvedBindings(bindings: ResolvedBinding[]): Injector {
528521
var bd = bindings.map(b => new BindingWithVisibility(b, Visibility.Public));
529522
var proto = new ProtoInjector(bd);
530-
var inj = new Injector(proto, null, depProvider);
531-
return inj;
523+
return new Injector(proto, null, null);
532524
}
533525

534526
_strategy: InjectorStrategy;
@@ -539,7 +531,7 @@ export class Injector {
539531
* Private
540532
*/
541533
constructor(public _proto: any /* ProtoInjector */, public _parent: Injector = null,
542-
private _depProvider: DependencyProvider = null,
534+
private _depProvider: any /* DependencyProvider */ = null,
543535
private _debugContext: Function = null) {
544536
this._strategy = _proto._strategy.createInjectorStrategy(this);
545537
}
@@ -636,9 +628,6 @@ export class Injector {
636628
* The passed-in bindings can be an array of `Type`, {@link Binding},
637629
* or a recursive array of more bindings.
638630
*
639-
* The methods also takes an optional {@link DependencyProvider}, which is used to
640-
* resolved dependencies that cannot be expressed as bindings.
641-
*
642631
* ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
643632
*
644633
* ```typescript
@@ -657,10 +646,9 @@ export class Injector {
657646
* because it needs to resolve the passed-in bindings first.
658647
* See {@link resolve} and {@link createChildFromResolved}.
659648
*/
660-
resolveAndCreateChild(bindings: Array<Type | Binding | any[]>,
661-
depProvider: DependencyProvider = null): Injector {
649+
resolveAndCreateChild(bindings: Array<Type | Binding | any[]>): Injector {
662650
var resolvedBindings = Injector.resolve(bindings);
663-
return this.createChildFromResolved(resolvedBindings, depProvider);
651+
return this.createChildFromResolved(resolvedBindings);
664652
}
665653

666654
/**
@@ -671,9 +659,6 @@ export class Injector {
671659
*
672660
* This API is the recommended way to construct injectors in performance-sensitive parts.
673661
*
674-
* The methods also takes an optional {@link DependencyProvider}, which is used to
675-
* resolved dependencies that cannot be expressed as bindings.
676-
*
677662
* ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
678663
*
679664
* ```typescript
@@ -691,11 +676,10 @@ export class Injector {
691676
* expect(child.get(ParentBinding)).toBe(parent.get(ParentBinding));
692677
* ```
693678
*/
694-
createChildFromResolved(bindings: ResolvedBinding[],
695-
depProvider: DependencyProvider = null): Injector {
679+
createChildFromResolved(bindings: ResolvedBinding[]): Injector {
696680
var bd = bindings.map(b => new BindingWithVisibility(b, Visibility.Public));
697681
var proto = new ProtoInjector(bd);
698-
var inj = new Injector(proto, null, depProvider);
682+
var inj = new Injector(proto, null, null);
699683
inj._parent = this;
700684
return inj;
701685
}

modules/angular2/test/core/di/injector_spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ export function main() {
109109
bindings: dynamicBindings,
110110
strategyClass: InjectorDynamicStrategy
111111
}].forEach((context) => {
112-
function createInjector(bindings: any[], dependencyProvider = null) {
113-
return Injector.resolveAndCreate(bindings.concat(context['bindings']), dependencyProvider);
112+
function createInjector(bindings: any[]) {
113+
return Injector.resolveAndCreate(bindings.concat(context['bindings']));
114114
}
115115

116116
describe(`injector ${context['strategy']}`, () => {
@@ -367,7 +367,8 @@ export function main() {
367367
depProvider.spy("getDependency").andReturn(e);
368368

369369
var bindings = Injector.resolve([Car]);
370-
var injector = Injector.fromResolvedBindings(bindings, depProvider);
370+
var proto = new ProtoInjector([new BindingWithVisibility(bindings[0], Visibility.Public)]);
371+
var injector = new Injector(proto, null, depProvider);
371372

372373
expect(injector.get(Car).engine).toEqual(e);
373374
expect(depProvider.spy("getDependency"))

modules/angular2/test/public_api_spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,6 @@ const NG_API = [
497497
'Key.get',
498498
'Key.numberOfKeys',
499499

500-
'KeyRegistry',
501-
'KeyRegistry.get',
502-
'KeyRegistry.numberOfKeys',
503-
504500
'KeyValueDiffers',
505501
'KeyValueDiffers.create',
506502
'KeyValueDiffers.extend',

0 commit comments

Comments
 (0)