Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: third_party/pkg/di/lib/module.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pkg/di/lib/generator.dart ('k') | third_party/pkg/di/lib/reflected_type.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/di/lib/module.dart
===================================================================
--- third_party/pkg/di/lib/module.dart (revision 33054)
+++ third_party/pkg/di/lib/module.dart (working copy)
@@ -22,7 +22,6 @@
*/
typedef bool Visibility(Injector requesting, Injector defining);
-typedef Object TypeFactory(factory(Type));
/**
* A collection of type bindings. Once the module is passed into the injector,
@@ -32,27 +31,7 @@
class Module {
final Map<Type, _Provider> _providers = <Type, _Provider>{};
final List<Module> _childModules = <Module>[];
- Map<Type, TypeFactory> _typeFactories = {};
- Map<Type, TypeFactory> get typeFactories {
- if (_childModules.isEmpty) {
- return _typeFactories;
- }
- var tmp = new Map.from(_typeFactories);
- _childModules.forEach((child) {
- if (child.typeFactories != null) {
- child.typeFactories.forEach((type, factory) {
- tmp[type] = factory;
- });
- }
- });
- return tmp;
- }
-
- set typeFactories(Map<Type, TypeFactory> factories) {
- _typeFactories = factories;
- }
-
Map<Type, _Provider> _providersCache;
/**
@@ -60,7 +39,7 @@
* child (installed) modules.
*/
Map<Type, _Provider> get _bindings {
- if (_isDirty) {
+ if (_providersCache == null) {
_providersCache = <Type, _Provider>{};
_childModules.forEach((child) => _providersCache.addAll(child._bindings));
_providersCache.addAll(_providers);
@@ -75,7 +54,7 @@
*/
void value(Type id, value,
{CreationStrategy creation, Visibility visibility}) {
- _dirty();
+ _providersCache = null;
_providers[id] = new _ValueProvider(value, creation, visibility);
}
@@ -88,7 +67,7 @@
*/
void type(Type id, {Type implementedBy, CreationStrategy creation,
Visibility visibility}) {
- _dirty();
+ _providersCache = null;
_providers[id] = new _TypeProvider(
implementedBy == null ? id : implementedBy, creation, visibility);
}
@@ -101,7 +80,7 @@
*/
void factory(Type id, FactoryFn factoryFn,
{CreationStrategy creation, Visibility visibility}) {
- _dirty();
+ _providersCache = null;
_providers[id] = new _FactoryProvider(factoryFn, creation, visibility);
}
@@ -111,15 +90,8 @@
*/
void install(Module module) {
_childModules.add(module);
- _dirty();
- }
-
- _dirty() {
_providersCache = null;
}
-
- bool get _isDirty =>
- _providersCache == null || _childModules.any((m) => m._isDirty);
}
/** Deafault creation strategy is to instantiate on the defining injector. */
« no previous file with comments | « third_party/pkg/di/lib/generator.dart ('k') | third_party/pkg/di/lib/reflected_type.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698