inject<T> method

void inject<T>(
  1. dynamic item, {
  2. dynamic args,
  3. bool withInjector = true,
  4. bool withArgs = true,
})

Injects and initializes given item with args. Set withInjector to inject given object. Set withArgs to init given object.

Initializable.init is called only when args are not null.

Control provides static call for this function via Control.inject.

Implementation

void inject<T>(dynamic item,
    {dynamic args, bool withInjector = true, bool withArgs = true}) {
  if (withInjector && _injector != null) {
    _injector!.inject<T?>(item, args);
  }

  if (withArgs && item is Initializable && args != null) {
    item.init(args is Map ? args : Parse.toMap(args));
  }
}