-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class RequestStatus { | ||
final String name; | ||
|
||
const RequestStatus._internal(this.name); | ||
|
||
static const RequestStatus IDLE = const RequestStatus._internal("IDLE"); | ||
static const RequestStatus WAITING = const RequestStatus._internal("WAITING"); | ||
static const RequestStatus DONE = const RequestStatus._internal("DONE"); | ||
static const RequestStatus ERROR = const RequestStatus._internal("ERROR"); | ||
|
||
@override | ||
String toString() => name; | ||
} | ||
|
||
class RequestObject<T> { | ||
T result; | ||
dynamic error; | ||
RequestStatus status; | ||
dynamic tag; //A dynamic value to identify this RequestObject | ||
|
||
RequestObject(this.result, this.status); | ||
|
||
RequestObject.done({this.result, this.tag}) { | ||
this.status = RequestStatus.DONE; | ||
} | ||
|
||
RequestObject.error({this.error, this.tag}) { | ||
this.status = RequestStatus.ERROR; | ||
} | ||
|
||
RequestObject.waiting({this.result, this.tag}) { | ||
this.status = RequestStatus.WAITING; | ||
} | ||
|
||
RequestObject.idle({this.result, this.tag}) { | ||
this.status = RequestStatus.IDLE; | ||
} | ||
|
||
@override | ||
String toString() => | ||
"RequestObject {$status} ${result != null ? "{$result}" : ""}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters