Permalink
Browse files

Merge pull request #1 from amiuhle/dart-update

Use proper types in the RouteEventList / Accept JSON responses.
  • Loading branch information...
2 parents 6f90a56 + ab4760b commit ed20f321379c012f9630447e1133c70d00955f5f Chris Strom committed Jul 5, 2012
Showing with 9 additions and 6 deletions.
  1. +2 −2 HipsterRouter.dart
  2. +7 −4 HipsterSync.dart
View
@@ -111,8 +111,8 @@ class RouterEventList implements EventListenerList {
listeners = [];
}
- RouterEventList add(fn) {
- listeners.add(fn);
+ RouterEventList add(EventListener handler, [bool useCapture]) {
+ listeners.add(handler);
return this;
}
View
@@ -43,14 +43,14 @@ class HipsterSync {
verb = _methodMap.containsKey(method) ?
_methodMap[method] : method;
- var request = new XMLHttpRequest(),
- completer = new Completer();
-
+ XMLHttpRequest request = new XMLHttpRequest();
+ Completer completer = new Completer();
+
request.
on.
load.
add((event) {
- var req = event.target;
+ XMLHttpRequest req = event.target;
if (req.status > 299) {
completer.
@@ -64,6 +64,9 @@ class HipsterSync {
request.open(verb, model.url, true);
+ // Tell the server that we expect JSON!
+ request.setRequestHeader("Accept", "application/json");
+
// POST and PUT HTTP request bodies if necessary
if (verb == 'post' || verb == 'put') {
request.setRequestHeader('Content-type', 'application/json');

0 comments on commit ed20f32

Please sign in to comment.