From c090988bc9415fb4babd24f2f8db18f90c024ad4 Mon Sep 17 00:00:00 2001 From: Igor Maculan Date: Fri, 30 Apr 2021 08:47:17 +0200 Subject: [PATCH] Issue #179 Added init method in the README example --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d128d02..c2dfb2f 100644 --- a/README.md +++ b/README.md @@ -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 init() async { + Future.delayed(Duration(seconds: 1)); + return this; + } + } + class RestService2 implements RestService{ + Future init() async { + Future.delayed(Duration(seconds: 1)); + return this; + } + } - getIt.registerSingletonAsync(() async => RestService1(), instanceName : "restService1"); - getIt.registerSingletonAsync(() async => RestService2(), instanceName : "restService2"); + getIt.registerSingletonAsync(() async => RestService1().init(), instanceName : "restService1"); + getIt.registerSingletonAsync(() async => RestService2().init(), instanceName : "restService2"); getIt.registerSingletonWithDependencies( () {