Skip to content

Commit

Permalink
Get rid of flow lib by inlining Promise.prototype.done polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
gabelevi committed Sep 15, 2016
1 parent 2c6edc4 commit 1cd633e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 54 deletions.
40 changes: 0 additions & 40 deletions packages/fbjs/flow/lib/Promise.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/fbjs/flow/lib/dev.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/fbjs/src/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
[include]
../node_modules/promise

[libs]
../flow/lib

[options]
module.system=haste

Expand Down
11 changes: 10 additions & 1 deletion packages/fbjs/src/core/Deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ class Deferred<Tvalue, Treason> {
}

done(): void {
Promise.prototype.done.apply(this._promise, arguments);
// Embed the polyfill for the non-standard Promise.prototype.done so that
// users of the open source fbjs don't need a custom lib for Promise
const promise = arguments.length ?
this._promise.then.apply(this._promise, arguments) :
this._promise;
promise.then(undefined, function(err) {
setTimeout(function() {
throw err;
}, 0);
});
}

isSettled(): boolean {
Expand Down

0 comments on commit 1cd633e

Please sign in to comment.