nonnel 0.0.4 nonnel: ^0.0.4 copied to clipboard
Helps to create dependency injection modules
A ridiculous dependency injection package for dart applications.
Features #
Create and instanciate dependencies. Create and instanciate name dependencies.
Getting started #
Install nonnel
dart pub global activate nonnel
Consider adding the dart pub global run
executables directory to your path.
See
Running a script from your PATH
for more details.
Usage #
First, import di_utils.dart
:
import 'di_utils.dart';
Then, create a factory (instance) for a dependency that you need:
factory(A());
Now, we can use an A
instance in another dependency using the inject<A>()
method:
factory(B(inject<A>()));
So, we can create named dependencies as below:
factory(D(), named: 'tchubaruba');
... and get it passing its name's as a parameter:
inject(named: 'tchubaruba');
We can create any factories and inject depencies in it:
factory( F( inject(named: 'tchubaruba'), inject<A>() ) );
Modules #
You can check how create module files in example/module.example.dart
: