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

Unified Diff: third_party/pkg/angular/lib/routing/routing.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
Index: third_party/pkg/angular/lib/routing/routing.dart
===================================================================
--- third_party/pkg/angular/lib/routing/routing.dart (revision 33054)
+++ third_party/pkg/angular/lib/routing/routing.dart (working copy)
@@ -9,126 +9,38 @@
ViewFactory(this.locationService);
call(String templateUrl) =>
- (RouteEnterEvent event) => _enterHandler(event, templateUrl);
-
- _enterHandler(RouteEnterEvent event, String templateUrl, [List<Module> modules]) =>
- locationService._route(event.route, templateUrl, fromEvent: true, modules: modules);
-
- configure(Map<String, NgRouteCfg> config) =>
- _configure(locationService.router.root, config);
-
- _configure(Route route, Map<String, NgRouteCfg> config) {
- config.forEach((name, cfg) {
- var moduledCalled = false;
- List<Module> newModules;
- route.addRoute(
- name: name,
- path: cfg.path,
- defaultRoute: cfg.defaultRoute,
- enter: (RouteEnterEvent e) {
- if (cfg.view != null) {
- _enterHandler(e, cfg.view, newModules);
- }
- if (cfg.enter != null) {
- cfg.enter(e);
- }
- },
- preEnter: (RoutePreEnterEvent e) {
- if (cfg.modules != null && !moduledCalled) {
- moduledCalled = true;
- var modules = cfg.modules();
- if (modules is Future) {
- e.allowEnter(modules.then((List<Module> m) {
- newModules = m;
- return true;
- }));
- } else {
- newModules = modules;
- }
- }
- if (cfg.preEnter != null) {
- cfg.preEnter(e);
- }
- },
- leave: cfg.leave,
- mount: (Route mountRoute) {
- if (cfg.mount != null) {
- _configure(mountRoute, cfg.mount);
- }
- });
- });
- }
+ (RouteEvent event) =>
+ locationService._route(event.route, templateUrl, fromEvent: true);
}
-NgRouteCfg ngRoute({String path, String view, Map<String, NgRouteCfg> mount,
- modules(), bool defaultRoute: false, RoutePreEnterEventHandler preEnter,
- RouteEnterEventHandler enter, RouteLeaveEventHandler leave}) =>
- new NgRouteCfg(path: path, view: view, mount: mount, modules: modules,
- defaultRoute: defaultRoute, preEnter: preEnter, enter: enter,
- leave: leave);
-
-class NgRouteCfg {
- final String path;
- final String view;
- final Map<String, NgRouteCfg> mount;
- final Function modules;
- final bool defaultRoute;
- final RouteEnterEventHandler enter;
- final RoutePreEnterEventHandler preEnter;
- final RouteLeaveEventHandler leave;
-
- NgRouteCfg({this.view, this.path, this.mount, this.modules, this.defaultRoute,
- this.enter, this.preEnter, this.leave});
-}
-
/**
* An interface that must be implemented by the user of routing library and
* should include the route initialization.
*
* The [init] method will be called by the framework once the router is
* instantiated but before [NgBindRouteDirective] and [NgViewDirective].
- *
- * Deprecated: use RouteInitializerFn instead.
*/
-@deprecated
abstract class RouteInitializer {
void init(Router router, ViewFactory viewFactory);
}
/**
- * An typedef that must be implemented by the user of routing library and
- * should include the route initialization.
- *
- * The function will be called by the framework once the router is
- * instantiated but before [NgBindRouteDirective] and [NgViewDirective].
- */
-typedef void RouteInitializerFn(Router router, ViewFactory viewFactory);
-
-/**
* A singleton helper service that handles routing initialization, global
* events and view registries.
*/
@NgInjectableService()
class NgRoutingHelper {
final Router router;
- final NgApp _ngApp;
List<NgViewDirective> portals = <NgViewDirective>[];
- Map<String, _View> _templates = new Map<String, _View>();
+ Map<String, String> _templates = new Map<String, String>();
- NgRoutingHelper(RouteInitializer initializer, Injector injector, this.router, this._ngApp) {
- // TODO: move this to constructor parameters when di issue is fixed:
- // https://github.com/angular/di.dart/issues/40
- RouteInitializerFn initializerFn = injector.get(RouteInitializerFn);
- if (initializer == null && initializerFn == null) {
+ NgRoutingHelper(RouteInitializer initializer, this.router) {
+ if (initializer == null) {
window.console.error('No RouteInitializer implementation provided.');
return;
};
- if (initializerFn != null) {
- initializerFn(router, new ViewFactory(this));
- } else {
- initializer.init(router, new ViewFactory(this));
- }
+ initializer.init(router, new ViewFactory(this));
router.onRouteStart.listen((RouteStartEvent routeEvent) {
routeEvent.completed.then((success) {
if (success) {
@@ -137,7 +49,7 @@
});
});
- router.listen(appRoot: _ngApp.root);
+ router.listen();
}
_reloadViews({Route startingFrom}) {
@@ -147,24 +59,23 @@
activePath = activePath.skip(_routeDepth(startingFrom));
}
for (Route route in activePath) {
- var viewDef = _templates[_routePath(route)];
- if (viewDef == null) continue;
- var templateUrl = viewDef.template;
+ var templateUrl = _templates[_routePath(route)];
+ if (templateUrl == null) continue;
NgViewDirective view = portals.lastWhere((NgViewDirective v) {
return _routePath(route) != _routePath(v._route) &&
_routePath(route).startsWith(_routePath(v._route));
}, orElse: () => null);
if (view != null && !alreadyActiveViews.contains(view)) {
- view._show(templateUrl, route, viewDef.modules);
+ view._show(templateUrl, route);
alreadyActiveViews.add(view);
break;
}
}
}
- _route(Route route, String template, {bool fromEvent, List<Module> modules}) {
- _templates[_routePath(route)] = new _View(template, modules);
+ _route(Route route, String template, {bool fromEvent}) {
+ _templates[_routePath(route)] = template;
}
_registerPortal(NgViewDirective ngView) {
@@ -176,13 +87,6 @@
}
}
-class _View {
- final String template;
- final List<Module> modules;
-
- _View(this.template, this.modules);
-}
-
String _routePath(Route route) {
var path = [];
var p = route;
« no previous file with comments | « third_party/pkg/angular/lib/routing/ng_view.dart ('k') | third_party/pkg/angular/lib/tools/expression_extractor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698