Last active
September 9, 2018 14:19
-
-
Save letsar/ed3345f64a7002b5e7d78192f93aceec 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'}) | |
@Register.factory(ServiceC, constructorName: 'other') | |
void configure(); | |
} | |
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() { | |
new _$Injector().configure(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment