Importing Binds

Importing Binds from Modules in ModularBr.

Importing Binds

When importing a bind from another module, the developer gains access to the same instance of the resource registered in the exporting module. This allows for greater modularity and code reuse across different parts of the application.

unit nfe.module;

interface

uses
  dmfbr.module,
  nfe.repository,
  nfe.provider;

type
  TNFeModule = class(TModule)
  public
    function Binds: TBinds; override;
    function Imports: TImports; override;
  end;

implementation

uses
  export.module;

{ TNFeModule }

function TNFeModule.Binds: TBinds;
begin
  // Dependency Injection
  Result := [Bind<TRepositoryServer>.SingletonLazy,
             Bind<TProviderORMBr>.Factory];
end;

function TNFeModule.Imports: TImports;
begin
  Result := [TExportModule];
end;

end.

WARNING

Module import is only for Binds. Routes will not be imported.

Last updated