Created
June 22, 2013 13:20
-
-
Save thara/5840840 to your computer and use it in GitHub Desktop.
Dependency Injection with Implicit Interfaces & Mix-in in Dart.
This file contains 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
main () { | |
new Service().execute(); | |
new AwesomeService().execute(); | |
} | |
class Repository { | |
List<String> find() => ["data1", "data2"]; | |
} | |
class Service { | |
Repository get repository => new Repository(); | |
void execute() => print(repository.find()); | |
} | |
class AwesomeRepository implements Repository { | |
List<String> find() => ["awesomeData1", "awesomeData2"]; | |
} | |
abstract class AwesomeRepositoryModule { | |
Repository get repository => new AwesomeRepository(); | |
} | |
typedef AwesomeService = Service with AwesomeRepositoryModule; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment