Permalink
Browse files

doc: Avoid main() async if using DI

  • Loading branch information...
MikeMitterer committed Jul 17, 2015
1 parent d25c473 commit 8b5a1d72b38f8cace5799545bfc2b9c53ec6cfa6
Showing with 36 additions and 0 deletions.
  1. +36 −0 README.md
View
@@ -101,6 +101,42 @@ main() async {
```
If you use **DI** initialize the mdl library as follows:
**DON'T USE ASYNC** otherwise you'll get an 'Uninitialized Module.DEFAULT_REFLECTOR' error
```dart
import 'package:mdl/mdl.dart' as mdl;
@MdlComponentModel @di.Injectable()
class Application extends mdl.MaterialApplication {
Application() {
}
@override
void run() {
// add your logic...
}
}
// Don't use async here - this would kill the di transformer
main() {
mdl.registerMdl();
componentFactory().rootContext(Application).addModule(new SampleModule()).run()
.then( (final MaterialApplication application) {
application.run();
});
}
class SampleModule extends di.Module {
SampleModule() {
// -- services (Example)
// bind(SignalService, toImplementation: SignalServiceImpl);
}
}
```
## Icons

0 comments on commit 8b5a1d7

Please sign in to comment.