Dependency Injection
With the Get
module you can easy inject your dependencies as a singleton, lazy singleton or as a factory.
#
Singletons#
Auto removeFirst make sure that you have added the meedu observer in your navigator observers more info.
Now when tou call to Get.i.put
or Get.i.lazyPut
you can use the autoRemove
parameter and set the value to true
then when the router who created the dependency
is popped the dependency will be deleted from memory.
#
Listen when a singleton was removedYou can use the onRemove
to define a callback to listen when a dependency will be deleted from memory, so when you call to Get.i.remove
or when you called to Get.i.put
or Get.i.lazyPut
using autoRemove
equals to true
the onRemove callback will be called.
#
FactoryIf you want to get a new instance every time you call find in that case you could use factoryPut
NOTE
If you want pass an initial value to AuthRepository
#
TestingTo avoid conflics with dependencies injected in the Get module you can clear the dependencies using a setUp
or a tearDown
before or after each test.