Details on working of Injector invoke method

Could any please explain me , what is the use of Injector.invoke() function ?

You can call #invoke with a function to ensure that its dependencies will be injected by the injector. That’s the core concept of dependency injection.

import { Injector } from "didi";

class Car {
  start() {
    console.log("Starting car");
  }
}

const carModule = {
  car: ["type", Car]
};

const injector = new Injector([carModule]);

// Using #invoke we can call a function that depends on `car` without having to worry about where it's coming from or how to instantiate it
injector.invoke(function (car) {
  car.start();
});

CodeSandbox: https://codesandbox.io/s/didi-example-4t5i1?file=/src/index.js:0-239

Thanks for the information. :slight_smile: