Skip to content

Commit

Permalink
v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jklmli committed Jan 1, 2017
1 parent e8f3fd7 commit afb7168
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/monapt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ declare module 'monapt' {
onComplete(callback: ICompleteFunction<T>): void;
onSuccess(callback: (value: T) => void): void;
onFailure(callback: (error: Error) => void): void;
map<U>(f: (value: T, promise: IFuturePromiseLike<U>) => void): Future<U>;
map<U>(f: (value: T) => U): Future<U>;
flatMap<U>(f: (value: T) => Future<U>): Future<U>;
filter(predicate: (value: T) => boolean): Future<T>;
reject(predicate: (value: T) => boolean): Future<T>;
recover(fn: (e: Error, promise: IFuturePromiseLike<T>) => void): Future<T>;
recover(fn: (e: Error) => T): Future<T>;
recoverWith(fn: (e: Error) => Future<T>): Future<T>;
}
class Promise<T> extends Future<T> {
Expand Down
12 changes: 10 additions & 2 deletions dist/monapt.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,15 @@ var monapt;
this.onComplete(function (r) {
r.match({
Failure: function (e) { return promise.failure(e); },
Success: function (v) { return f(v, F(promise)); }
Success: function (v) {
try {
var result = f(v);
promise.success(result);
}
catch (e) {
promise.failure(e);
}
}
});
});
return promise.future();
Expand Down Expand Up @@ -423,7 +431,7 @@ var monapt;
r.match({
Failure: function (error) {
try {
fn(error, F(promise));
promise.success(fn(error));
}
catch (e) {
promise.failure(e);
Expand Down
Loading

0 comments on commit afb7168

Please sign in to comment.