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

Side by Side Diff: samples/third_party/todomvc_performance/web/lib-elements/polymer_localstorage.dart

Issue 1576153002: Remove the Dromaeo and TodoMVC samples. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
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.polymer_localstorage;
5
6 import 'dart:convert' show JSON;
7 import 'dart:html';
8 import 'package:polymer/polymer.dart';
9
10 // TODO(jmesserly): replace with interop to <polymer-localstorage>.
11 @CustomTag('polymer-localstorage')
12 class PolymerLocalStorage extends PolymerElement {
13 @published String name;
14 @published var value;
15 @published bool useRaw = false;
16
17 factory PolymerLocalStorage() => new Element.tag('polymer-localstorage');
18 PolymerLocalStorage.created() : super.created();
19
20 void ready() {
21 load();
22 }
23
24 void valueChanged() {
25 save();
26 }
27
28 void load() {
29 var s = window.localStorage[name];
30 if (s != null && !useRaw) {
31 value = JSON.decode(s);
32 } else {
33 value = s;
34 }
35 }
36
37 void save() {
38 window.localStorage[name] = useRaw ? value : JSON.encode(value);
39 }
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698