Last active
September 9, 2018 14:18
-
-
Save letsar/66ad9e16ed4ff71f33cbc5ca1e176f59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:kiwi/kiwi.dart'; | |
part 'test01.g.dart'; | |
abstract class Injector { | |
@Register.singleton(ServiceA) | |
@Register.factory(Service, from: ServiceB) | |
@Register.factory(ServiceB, name: 'factoryB') | |
@Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'}) | |
void common(); | |
@Register.factory(ServiceC) | |
void development(); | |
@Register.factory(ServiceC, constructorName: 'other') | |
void production(); | |
} | |
class Service {} | |
class ServiceA extends Service {} | |
class ServiceB extends Service { | |
ServiceB(ServiceA serviceA); | |
} | |
class ServiceC extends Service { | |
ServiceC(ServiceA serviceA, ServiceB serviceB); | |
ServiceC.other(ServiceB serviceA); | |
} | |
void setup(bool isProduction) { | |
var injector = _$Injector(); | |
injector.common(); | |
if (isProduction) { | |
injector.production(); | |
} else { | |
injector.development(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment