Patrice Chalin c1440e7eff [review-pending] docs(dev guide): server-communication - new prose
New Dart prose, update Dart and Ts code

+ guide/server-communication/ts: update to docs and example code
+ guide/server-communication/dart: new prose, update example code
+ ignore all npm-debug.logs
+ make Jade ul li TOC elements more compact.
2016-05-13 21:32:54 +01:00

15 lines
305 B
Dart

// #docregion
class Hero {
final int id;
final String name;
Hero(this.id, this.name);
factory Hero.fromJson(Map<String, dynamic> hero) =>
new Hero(_toInt(hero['id']), hero['name']);
Map toJson() => {'id': id, 'name': name};
static int _toInt(id) => id is int ? id : int.parse(id);
}