Skip to content

Commit

Permalink
Issue #179 Added init method in the README example
Browse files Browse the repository at this point in the history
  • Loading branch information
n3wtron committed Apr 30, 2021
1 parent 467bd77 commit c090988
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,21 @@ factories/singletons that were registered by name.

```Dart
abstract class RestService {}
class RestService1 implements RestService{}
class RestService2 implements RestService{}
class RestService1 implements RestService{
Future<RestService1> init() async {
Future.delayed(Duration(seconds: 1));
return this;
}
}
class RestService2 implements RestService{
Future<RestService2> init() async {
Future.delayed(Duration(seconds: 1));
return this;
}
}
getIt.registerSingletonAsync<RestService>(() async => RestService1(), instanceName : "restService1");
getIt.registerSingletonAsync<RestService>(() async => RestService2(), instanceName : "restService2");
getIt.registerSingletonAsync<RestService>(() async => RestService1().init(), instanceName : "restService1");
getIt.registerSingletonAsync<RestService>(() async => RestService2().init(), instanceName : "restService2");
getIt.registerSingletonWithDependencies<AppModel>(
() {
Expand Down

0 comments on commit c090988

Please sign in to comment.