Skip to content

Commit

Permalink
Dart breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuLorber authored and passy committed Nov 4, 2013
1 parent 2c56ac4 commit 64a3971
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
24 changes: 12 additions & 12 deletions architecture-examples/dart/web/dart/TodoApp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ part of todomvc;
class TodoApp {
List<TodoWidget> todoWidgets = new List<TodoWidget>();

Element todoListElement = query('#todo-list');
Element mainElement = query('#main');
InputElement checkAllCheckboxElement = query('#toggle-all');
Element footerElement = query('#footer');
Element countElement = query('#todo-count');
Element clearCompletedElement = query('#clear-completed');
Element showAllElement = query('#filters a[href="#/"]');
Element showActiveElement = query('#filters a[href="#/active"]');
Element showCompletedElement = query('#filters a[href="#/completed"]');
Element todoListElement = querySelector('#todo-list');
Element mainElement = querySelector('#main');
InputElement checkAllCheckboxElement = querySelector('#toggle-all');
Element footerElement = querySelector('#footer');
Element countElement = querySelector('#todo-count');
Element clearCompletedElement = querySelector('#clear-completed');
Element showAllElement = querySelector('#filters a[href="#/"]');
Element showActiveElement = querySelector('#filters a[href="#/active"]');
Element showCompletedElement = querySelector('#filters a[href="#/completed"]');

TodoApp() {
initLocalStorage();
Expand All @@ -26,7 +26,7 @@ class TodoApp {
var jsonList = window.localStorage['todos-vanilladart'];
if (jsonList != null) {
try {
var todos = JSON.parse(jsonList);
var todos = JSON.decode(jsonList);
for (Map todo in todos) {
addTodo(new Todo.fromJson(todo));
}
Expand All @@ -37,7 +37,7 @@ class TodoApp {
}

void initElementEventListeners() {
InputElement newTodoElement = query('#new-todo');
InputElement newTodoElement = querySelector('#new-todo');

newTodoElement.onKeyPress.listen((KeyboardEvent e) {
if (e.keyCode == KeyCode.ENTER) {
Expand Down Expand Up @@ -160,6 +160,6 @@ class TodoApp {
for (TodoWidget todoWidget in todoWidgets) {
todos.add(todoWidget.todo);
}
window.localStorage['todos-vanilladart'] = JSON.stringify(todos);
window.localStorage['todos-vanilladart'] = JSON.encode(todos);
}
}
3 changes: 2 additions & 1 deletion architecture-examples/dart/web/dart/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library todomvc;

import 'dart:html';
import 'dart:math';
import 'dart:json' as JSON;
import 'dart:convert';

part 'TodoWidget.dart';
part 'TodoApp.dart';
Expand All @@ -24,6 +24,7 @@ class Todo {
completed = json['completed'];
}

// this is automatically called by JSON.encode
Map toJson() {
return {'id': id, 'title': title, 'completed': completed};
}
Expand Down

0 comments on commit 64a3971

Please sign in to comment.