Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions HipsterModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ class HipsterModel implements Hashable {
/// Returns true if the model has been _previously_ saved to the backend (not
/// if the most recent changes have been saved).
bool isSaved() => id != null;

/// TODO
Future<HipsterModel> fetch() {
Completer<HipsterModel> completer = new Completer<HipsterModel>();
Future after_call = HipsterSync.call('get', this);

after_call.
then((attrs) {
this.attributes = attrs;
on.load.dispatch(new ModelEvent('load', this));
completer.complete(this);
});

after_call.handleException((e) {
completer.completeException(e);
return true;
});

return completer.future;
}

/// Either creates or updates this record in the backend datastore. This
/// method returns a [Future] that can be used to perform subsequent actions
Expand Down