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

Side by Side Diff: samples/third_party/todomvc/web/lib-elements/simple_router.dart

Issue 60353013: Update TodoMVC based on https://github.com/polymer/todomvc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Polymer Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 library todomvc.web.lib_elements.simple_router;
5
6 import 'dart:async';
7 import 'dart:html';
8 import 'package:polymer/polymer.dart';
9
10 // A very simple router for TodoMVC. Real app should use package:route, but it
11 // does not currently support Shadow DOM.
12 @CustomTag('simple-router')
13 class SimpleRouter extends PolymerElement {
14 @published String route = '';
15
16 StreamSubscription _sub;
17
18 factory SimpleRouter() => new Element.tag('simple-router');
19 SimpleRouter.created() : super.created();
20
21 enteredView() {
22 _sub = windowLocation.changes.listen((_) {
23 var hash = window.location.hash;
24 if (hash.startsWith('#/')) hash = hash.substring(2);
25 // TODO(jmesserly): empty string is not triggering a call to TodoList
26 // routeChanged after deployment. Use 'all' as a workaround.
27 if (hash == '') hash = 'all';
28 route = hash;
29 });
30 }
31
32 leftView() {
33 _sub.cancel();
34 }
35
36 routeChanged() {
37 fire('route', detail: route);
38 }
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698