Permalink
Browse files

feature: Removed depencency to DI, switched over to Dice

  • Loading branch information...
MikeMitterer committed May 5, 2017
1 parent e19d0e8 commit 49d5c71d558ca35eb5b0adf3e68d256f88470dee
Showing with 109 additions and 85 deletions.
  1. +9 −9 lib/mdlapplication.dart
  2. +1 −1 lib/mdlcomponents.dart
  3. +1 −1 lib/mdlcore.dart
  4. +1 −1 lib/mdldemo.dart
  5. +1 −1 lib/mdldialog.dart
  6. +5 −4 lib/mdldirective.dart
  7. +1 −1 lib/mdldnd.dart
  8. +2 −1 lib/mdlflux.dart
  9. +1 −1 lib/mdlform.dart
  10. +5 −5 lib/mdlformatter.dart
  11. +2 −2 lib/mdlmock.dart
  12. +4 −4 lib/mdltemplate.dart
  13. +1 −1 lib/src/application/components/MaterialContent.dart
  14. +1 −1 lib/src/application/components/MaterialInclude.dart
  15. +1 −1 lib/src/application/modules/DomRenderer.dart
  16. +1 −1 lib/src/application/modules/EventCompiler.dart
  17. +2 −2 lib/src/application/modules/Scope.dart
  18. +1 −1 lib/src/application/modules/ViewFactory.dart
  19. +1 −0 lib/src/components/MaterialLabelfield.dart
  20. +1 −1 lib/src/core/MdlComponent.dart
  21. +17 −6 lib/src/core/MdlComponentHandler.dart
  22. +1 −1 lib/src/core/interfaces.dart
  23. +1 −1 lib/src/dialog/MaterialAlertDialog.dart
  24. +1 −1 lib/src/dialog/MaterialConfirmDialog.dart
  25. +1 −1 lib/src/dialog/MaterialDialog.dart
  26. +1 −1 lib/src/dialog/MaterialNotification.dart
  27. +1 −1 lib/src/dialog/MaterialSnackbar.dart
  28. +1 −1 lib/src/directive/components/MaterialAttribute.dart
  29. +7 −4 lib/src/directive/components/MaterialClass.dart
  30. +2 −2 lib/src/directive/components/MaterialModel.dart
  31. +3 −5 lib/src/directive/components/MaterialObserve.dart
  32. +1 −1 lib/src/directive/components/model/ModelObserverFactory.dart
  33. +2 −1 lib/src/flux/ActionBusImpl.dart
  34. +4 −3 lib/src/flux/DataStore.dart
  35. +5 −4 lib/src/form/components/MaterialFormComponent.dart
  36. +1 −1 lib/src/formatter/components/MaterialFormatter.dart
  37. +2 −2 lib/src/formatter/utils/FormatterPipeline.dart
  38. +1 −0 lib/src/observable/ObservableProperty.dart
  39. +1 −1 lib/src/template/MdlTemplateComponent.dart
  40. +1 −1 lib/src/template/components/MaterialMustache.dart
  41. +4 −4 lib/src/template/components/MaterialRepeat.dart
  42. +1 −1 lib/src/template/modules/ListRenderer.dart
  43. +2 −1 lib/src/template/modules/TemplateRenderer.dart
  44. +6 −2 pubspec.yaml
View
@@ -30,7 +30,7 @@ import 'dart:js';
import 'package:logging/logging.dart';
import 'package:validate/validate.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:route_hierarchical/client.dart';
@@ -69,16 +69,16 @@ part "src/application/Utils.dart";
*/
class MdlModule extends di.Module {
MdlModule() {
bind(MaterialApplication);
configure() {
register(MaterialApplication);
bind(DomRenderer);
bind(EventCompiler);
bind(ViewFactory);
bind(RootScope);
register(DomRenderer);
register(EventCompiler);
register(ViewFactory);
register(RootScope);
bind(ActionBus, toImplementation: ActionBusImpl);
bind(DataStore, toImplementation: FireOnlyDataStore);
register(ActionBus).toType(ActionBusImpl);
register(DataStore).toType(FireOnlyDataStore);
}
}
View
@@ -24,7 +24,7 @@ import 'dart:math' as Math;
import 'dart:async';
import 'package:logging/logging.dart';
import 'package:browser_detect/browser_detect.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:validate/validate.dart';
import "package:mdl/mdlcore.dart";
View
@@ -30,7 +30,7 @@ import 'dart:js';
import 'package:logging/logging.dart';
import 'package:validate/validate.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:mdl/src/core/annotations.dart';
View
@@ -21,7 +21,7 @@ library mdldemo;
import 'dart:html' as dom;
import 'package:logging/logging.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import "package:mdl/mdlcore.dart";
import "package:mdl/mdlcomponents.dart";
View
@@ -25,7 +25,7 @@ import 'dart:async';
import 'package:logging/logging.dart';
import 'package:mustache/mustache.dart';
import 'package:validate/validate.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:mdl/mdlcore.dart';
import 'package:mdl/mdlcomponents.dart';
View
@@ -28,7 +28,7 @@ import 'dart:collection';
import 'package:logging/logging.dart';
import 'package:validate/validate.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:mdl/mdlcore.dart';
import 'package:mdl/mdlcomponents.dart';
@@ -51,9 +51,10 @@ part "src/directive/components/model/ModelObserver.dart";
part "src/directive/utils.dart";
class MdlDirectiveModule extends di.Module {
MdlDirectiveModule() {
bind(ModelObserverFactory);
}
@override
configure() {
register(ModelObserverFactory);
}
}
final MdlDirectiveModule _directiveModule = new MdlDirectiveModule();
View
@@ -21,7 +21,7 @@ library mdldnd;
import 'dart:html' as dom;
import 'package:logging/logging.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:validate/validate.dart';
import 'package:dnd/dnd.dart';
View
@@ -51,7 +51,8 @@ library mdlflux;
import 'dart:async';
import 'dart:convert';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:mdl/src/core/annotations.dart';
import 'package:validate/validate.dart';
part "src/flux/interfaces.dart";
View
@@ -23,7 +23,7 @@ import 'dart:async';
import 'dart:html' as dom;
import 'package:logging/logging.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:mdl/mdlcore.dart';
import 'package:mdl/mdlcomponents.dart';
View
@@ -22,7 +22,7 @@ library mdlformatter;
import 'dart:html' as dom;
import 'dart:collection';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:intl/intl.dart';
import 'package:logging/logging.dart';
import 'package:validate/validate.dart';
@@ -46,7 +46,7 @@ part 'src/formatter/UpperCaseFormatter.dart';
* Formatter ist a collection of formatters.
* To add your own formatter follow the sample below
*
* @MdlComponentModel @di.Injectable()
* @MdlComponentModel @di.inject
* class MyFormatter extends Formatter {
*
* // Your super cool formatter
@@ -76,7 +76,7 @@ part 'src/formatter/UpperCaseFormatter.dart';
* or
* <div class="mdl-labelfield" mdl-formatter="uppercase(value)">...</div>
*/
@MdlComponentModel @di.Injectable()
@MdlComponentModel @di.inject
class Formatter {
final NumberFormatter number = new NumberFormatter();
final DecoratorFormatter decorate = new DecoratorFormatter();
@@ -87,8 +87,8 @@ class Formatter {
/// Makes Formatter available in DI
class MdlFormatterModule extends di.Module {
MdlFormatterModule() {
bind(Formatter);
configure() {
register(Formatter);
}
}
final MdlFormatterModule _formatterModule = new MdlFormatterModule();
View
@@ -39,7 +39,7 @@ library mdlmock;
//import 'package:validate/validate.dart';
import 'dart:mirrors';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
import 'package:mdl/mdlapplication.dart';
export 'package:mdl/mdlcore.dart' show mockComponentHandler;
@@ -100,7 +100,7 @@ class _MdlInjector {
/// Creates the "Injector" also called by the global [injector()] Function
void _create() {
if(_injector == null) {
_injector = new di.ModuleInjector(_modules);
_injector = new di.Injector.fromModules(_modules);
}
}
}
View
@@ -28,7 +28,7 @@ import 'dart:async';
import 'package:logging/logging.dart';
import 'package:validate/validate.dart';
import 'package:mustache/mustache.dart';
import 'package:di/di.dart' as di;
import 'package:dice/dice.dart' as di;
//import 'package:mdl/mustache.dart';
@@ -49,9 +49,9 @@ part "src/template/modules/TemplateRenderer.dart";
part "src/template/modules/ListRenderer.dart";
class MdlTemplateModule extends di.Module {
MdlTemplateModule() {
bind(TemplateRenderer);
bind(ListRenderer);
configure() {
register(TemplateRenderer);
register(ListRenderer);
}
}
final MdlTemplateModule _templateModule = new MdlTemplateModule();
@@ -46,7 +46,7 @@ class MaterialContent extends MdlComponent {
final DomRenderer _renderer;
MaterialContent.fromElement(final dom.HtmlElement element,final di.Injector injector)
: _renderer = injector.get(DomRenderer), super(element,injector) {
: _renderer = injector.getInstance(DomRenderer), super(element,injector) {
_init();
}
@@ -58,7 +58,7 @@ class MaterialInclude extends MdlComponent {
Stream<MaterialContentEvent> onLoadEnd;
MaterialInclude.fromElement(final dom.HtmlElement element,final di.Injector injector)
: _renderer = injector.get(DomRenderer), super(element,injector) {
: _renderer = injector.getInstance(DomRenderer), super(element,injector) {
onLoadEnd = _controller.stream as Stream<MaterialContentEvent>;
_init();
@@ -37,7 +37,7 @@ typedef void _DomRenderFunction();
* DomRenderer converts a String into HtmlNodes
*
*/
@di.Injectable()
@MdlComponentModel
class DomRenderer {
final Logger _logger = new Logger('mdlapplication.DomRenderer');
@@ -26,7 +26,7 @@ typedef _EventHandler(final dom.Element element,invoke(final dom.Event event));
*
* Needed in mdltemplatecomponents!
*/
@di.Injectable()
@MdlComponentModel
class EventCompiler {
static final Logger _logger = new Logger('mdlapplication.EventCompiler');
@@ -24,7 +24,7 @@ Object mdlRootContext() {
Object rootContext;
try {
rootContext = componentFactory().injector.get(MaterialApplication);
rootContext = componentFactory().injector.getInstance(MaterialApplication);
}
on Error catch(e,stack) {
_logger.shout(e,stack);
@@ -93,7 +93,7 @@ class Scope {
//- private -----------------------------------------------------------------------------------
}
@di.Injectable()
@MdlComponentModel
class RootScope extends Scope {
RootScope() : super(mdlRootContext(),null);
}
@@ -39,7 +39,7 @@ part of mdlapplication;
* router.listen();
* }
*/
@di.Injectable()
@MdlComponentModel
class ViewFactory {
final Logger _logger = new Logger('mdlremote.ViewFactory');
@@ -29,6 +29,7 @@ part of mdlcomponents;
/// label.label = "Another search engine";
/// label.value = "Yahoo";
///
@MdlComponentModel
class MaterialLabelfield extends MdlComponent with FallbackFormatter {
final Logger _logger = new Logger('mdlcomponents.MaterialLabelfield');
@@ -34,7 +34,7 @@ abstract class MdlComponent extends Object with MdlEventListener {
*
* componentFactory().addModule(new StyleguideModule())
* .run().then(( final di.Injector injector) {
* final Model model = injector.get(Model);
* final Model model = injector.getInstance(Model);
* });
* });
*
@@ -26,6 +26,17 @@ class MultipleWidgetException implements Exception {
MultipleWidgetException([this.message]);
}
class _ApplicationModule extends di.Module {
final Type _rootContext;
_ApplicationModule(this._rootContext);
@override
configure() {
register(MaterialApplication).toType(_rootContext).asSingleton();
}
}
/// Property for the Components JsObject to save/register the component
const String MDL_COMPONENT_PROPERTY = "mdlcomponent";
@@ -232,15 +243,15 @@ class MdlComponentHandler {
_injector = _createInjector();
return upgradeElement(body).then((_) => new Future<MaterialApplication>(() {
return _injector.get(MaterialApplication) as MaterialApplication;
return _injector.getInstance(MaterialApplication) as MaterialApplication;
}));
}
/**
* In most cases this is your AppController
*
* Sample:
* @MdlComponentModel @di.Injectable()
* @MdlComponentModel
* class AppController {
*
* }
@@ -254,7 +265,7 @@ class MdlComponentHandler {
* }
*/
MdlComponentHandler rootContext(final Type rootContext) {
_modules.add(new di.Module()..bind(MaterialApplication, toImplementation: rootContext));
_modules.add(new _ApplicationModule(rootContext));
return this;
}
@@ -279,7 +290,7 @@ class MdlComponentHandler {
*
* Define it like this:
*
* @MdlComponentModel @di.Injectable()
* @MdlComponentModel
* class Application extends MaterialApplication {
* Application() { }
*
@@ -300,7 +311,7 @@ class MdlComponentHandler {
*
*/
MaterialApplication get application {
return injector.get(MaterialApplication);
return injector.getInstance(MaterialApplication);
}
//- private -----------------------------------------------------------------------------------
@@ -498,7 +509,7 @@ class MdlComponentHandler {
* dependency injection.
*/
di.Injector _createInjector() {
return new di.ModuleInjector(_modules);
return new di.Injector.fromModules(_modules);
}
/// Downgrades the given {element} with all it's components
@@ -41,7 +41,7 @@ part of mdlcore;
* });
* }
*/
@MdlComponentModel @di.Injectable()
@MdlComponentModel
class MaterialApplication {
void run() {}
}
@@ -1,6 +1,6 @@
part of mdldialog;
@MdlComponentModel @di.Injectable()
@MdlComponentModel
class MaterialAlertDialog extends MaterialDialog {
static final Logger _logger = new Logger('mdldialog.MaterialAlertDialog');
@@ -1,6 +1,6 @@
part of mdldialog;
@MdlComponentModel @di.Injectable()
@MdlComponentModel
class MdlConfirmDialog extends MaterialDialog {
static final Logger _logger = new Logger('mdldialog.MdlConfirmDialog');
@@ -386,7 +386,7 @@ abstract class MaterialDialog extends Object with TemplateComponent, MdlEventLis
}
Future _render() {
final TemplateRenderer templateRenderer = componentFactory().injector.get(TemplateRenderer);
final TemplateRenderer templateRenderer = componentFactory().injector.getInstance(TemplateRenderer);
return templateRenderer.render(_dialogContainer,this,
() => template,replaceNode: !_config.appendNewDialog);
@@ -28,7 +28,7 @@ enum NotificationType {
}
/// MaterialNotification
@MdlComponentModel @di.Injectable()
@MdlComponentModel
class MaterialNotification extends MaterialDialog {
static final Logger _logger = new Logger('mdldialog.MaterialNotification');
Oops, something went wrong.

0 comments on commit 49d5c71

Please sign in to comment.