Commit 9b5e8b15 authored by Sindre Sorhus's avatar Sindre Sorhus

Merge pull request #467 from MathieuLorber/dartm3pr

Dart sample syntax & README up to date
parents 9005b8d2 da4639f6
packages
out
app.dart.js.deps
app.dart.js.map
pubspec.lock
\ No newline at end of file
name: todomvc-dart
description: TodoMVC built with Dart
name: todomvc_dart
version: 0.0.1
description: TodoMVC built with Dart
......@@ -8,9 +8,33 @@ Dart firstly targets the development of modern and large scale browser-side web
Dart compiles to JavaScript and thus runs across modern browsers. Dart also can run in its own virtual machine.
To edit and debug Dart, you can use Dart Editor. The editor ships with the [SDK](http://dartlang.org) and [Dartium](http://www.dartlang.org/dartium/), our version of Chromium with an embedded Dart VM.
Both Dart files and JS compilation result are provided in this sample, therefore it actually works in any browser.
For testing purpose, dart/app.dart will run on any browser thanks to sdk/dart.js. First run will take time to process dart files.
To edit and debug the code, you can use Dart Editor. The editor ships with the [SDK](http://dartlang.org) and [Dartium](http://www.dartlang.org/dartium/), a dedicated version of Chromium with an embedded Dart VM.
## How to compile to JS
```
cd web/dart
dart2js app.dart -oapp.dart.js
```
The dart2js compilator can be found in the SDK.
The currently provided JS is minified (dart2js [...] --minify).
## Dart syntax analysis
```
cd web/dart
dart_analyzer app.dart --fatal-type-errors --fatal-warnings
```
Dart SDK is still under active development, and new releases include breaking changes. The application is built by drone.io, which proposes a specific build trigger for Dart SDK updates.
[![Build Status](https://drone.io/mlorber/todomvc-dart/status.png)](https://drone.io/mlorber/todomvc-dart/latest)
Build history can be seen [here](https://drone.io/mlorber/todomvc-dart)
## Credit
......
......@@ -17,7 +17,7 @@ class TodoApp {
initLocalStorage();
initElementEventListeners();
window.on.hashChange.add((e) => updateFilter());
window.onHashChange.listen((e) => updateFilter());
updateFooterDisplay();
}
......@@ -39,7 +39,7 @@ class TodoApp {
void initElementEventListeners() {
InputElement newTodoElement = query('#new-todo');
newTodoElement.on.keyPress.add((KeyboardEvent e) {
newTodoElement.onKeyPress.listen((KeyboardEvent e) {
if (e.keyCode == KeyCode.ENTER) {
var title = newTodoElement.value.trim();
if (title != '') {
......@@ -51,7 +51,7 @@ class TodoApp {
}
});
checkAllCheckboxElement.on.click.add((Event e) {
checkAllCheckboxElement.onClick.listen((e) {
for (TodoWidget todoWidget in todoWidgets) {
if (todoWidget.todo.completed != checkAllCheckboxElement.checked) {
todoWidget.toggle();
......@@ -61,7 +61,7 @@ class TodoApp {
save();
});
clearCompletedElement.on.click.add((MouseEvent e) {
clearCompletedElement.onClick.listen((e) {
var newList = new List<TodoWidget>();
for (TodoWidget todoWidget in todoWidgets) {
if (todoWidget.todo.completed) {
......
......@@ -25,13 +25,13 @@ class TodoWidget {
toggleElement = element.query('.toggle');
toggleElement.on.click.add((MouseEvent e) {
toggleElement.onClick.listen((e) {
toggle();
todoApp.updateCounts();
todoApp.save();
});
contentElement.on.doubleClick.add((MouseEvent e) {
contentElement.onDoubleClick.listen((e) {
element.classes.add('editing');
editElement.selectionStart = todo.title.length;
editElement.focus();
......@@ -43,12 +43,12 @@ class TodoWidget {
todoApp.updateFooterDisplay();
}
element.query('.destroy').on.click.add((MouseEvent e) {
element.query('.destroy').onClick.listen((e) {
removeTodo();
todoApp.save();
});
void doneEditing(event) {
void doneEditing() {
todo.title = editElement.value.trim();
if (todo.title != '') {
contentElement.text = todo.title;
......@@ -59,13 +59,13 @@ class TodoWidget {
todoApp.save();
}
editElement.on
..keyPress.add((KeyboardEvent e) {
editElement
..onKeyPress.listen((KeyboardEvent e) {
if (e.keyCode == KeyCode.ENTER) {
doneEditing(e);
doneEditing();
}
})
..blur.add(doneEditing);
..onBlur.listen((e) => doneEditing());
return element;
}
......
......@@ -2,7 +2,7 @@ library todomvc;
import 'dart:html';
import 'dart:math';
import 'dart:json';
import 'dart:json' as JSON;
part 'TodoWidget.dart';
part 'TodoApp.dart';
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment