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

Unified Diff: 2-4-extended/lib/common/messages.dart

Issue 1056193003: Rename methods to better match new terminology and get rid of json data file. (Closed) Base URL: https://github.com/dart-lang/one-hour-codelab.git@server2
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 2-2-simple/lib/server/piratesapi.dart ('k') | 2-4-extended/lib/common/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 2-4-extended/lib/common/messages.dart
diff --git a/2-4-extended/lib/common/messages.dart b/2-4-extended/lib/common/messages.dart
index 74d94a23f75275182ca790be7cb785a3f13efc48..b1aff3654207b296530f90ddda13920968b0427f 100644
--- a/2-4-extended/lib/common/messages.dart
+++ b/2-4-extended/lib/common/messages.dart
@@ -4,8 +4,8 @@
library pirate.messages;
-import 'dart:convert' show JSON;
-
+// This class is used to send data back and forth between the client and server.
+// It is automatically serialized and deserialized by the RPC package.
class Pirate {
String name;
String appellation;
@@ -14,19 +14,11 @@ class Pirate {
Pirate();
// It is fine to have other named constructors.
- Pirate.fromJSON(String jsonString) {
- Map storedName = JSON.decode(jsonString);
- name = storedName['f'];
- appellation = storedName['a'];
- }
-
Pirate.fromString(String pirateName) {
var parts = pirateName.split(' the ');
name = parts[0];
appellation = parts[1];
}
- String get jsonString => JSON.encode({"f": name, "a": appellation});
-
String toString() => name.isEmpty ? '' : '$name the $appellation';
}
« no previous file with comments | « 2-2-simple/lib/server/piratesapi.dart ('k') | 2-4-extended/lib/common/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698