Skip to content

Commit

Permalink
Collection methods should return futures.
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
eee-c committed Sep 1, 2013
1 parent cfa6a8e commit ed31db5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
27 changes: 12 additions & 15 deletions lib/hipster_collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ abstract class HipsterCollection implements Iterable {
return ret;
}

fetch() {
HipsterSync.
Future<Map> fetch() {
return HipsterSync.
call('read', this).
then((list) {
list.forEach((attrs) {
Expand All @@ -49,19 +49,16 @@ abstract class HipsterCollection implements Iterable {
});
}

create(attrs) {
Future after_save = _buildModel(attrs).save();

after_save.
then((saved_model) {
this.add(saved_model);
});

after_save.
catchError((e) {
print("Exception handled: ${e}");
return true;
});
Future<dynamic> create(attrs) {
return _buildModel(attrs).
save()
..then((saved_model) {
this.add(saved_model);
})
..catchError((e) {
print("Exception handled: ${e}");
return true;
});
}

add(model) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hipster_mvc
version: 0.2.10
version: 0.2.11
description: Dart-based MVC framework
author: Chris Strom <chris@eeecomputes.com>
homepage: https://github.com/eee-c/hipster-mvc
Expand Down

0 comments on commit ed31db5

Please sign in to comment.