InjectorFactory typedef

Injector InjectorFactory ([Injector parent ])

Defines a function that creates an injector around a parent injector.

An InjectorFactory can be as simple as a closure or function:

class Example {}

/// Returns an [Injector] that provides an `Example` service.
Injector createInjector([Injector parent]) {
  return new Injector.map({
    Example: new Example(),
  }, parent);
}

void main() {
  var injector = createInjector();
  print(injector.get(Example)); // 'Instance of Example'.
}

You may also generate an InjectorFactory using GenerateInjector.

Implementation

typedef InjectorFactory = Injector Function([Injector parent]);