Skip to content

Commit

Permalink
fix(makePromise): support HandledPromise.unwrap(p)
Browse files Browse the repository at this point in the history
When used locally, regular Promises don't support unwrap, since
they have not travelled through SwingSet's comms system (which
makes them all HandledPromises).

Using HandledPromise here enables unwrap(p) to be used even if
there is no intervening comms system.
  • Loading branch information
michaelfig committed Feb 28, 2020
1 parent 4cae336 commit fb98636
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/make-promise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
"dependencies": {
"@agoric/eventual-send": "^0.5.0",
"@agoric/harden": "^0.0.4"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion packages/make-promise/src/makePromise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import harden from '@agoric/harden';
import { HandledPromise } from '@agoric/eventual-send';

export default function makePromise() {
let res;
let rej;
const p = new Promise((resolve, reject) => {
// We use a HandledPromise so that we can run HandledPromise.unwrap(p)
// even if p doesn't travel through a comms system (like SwingSet's).
const p = new HandledPromise((resolve, reject) => {
res = resolve;
rej = reject;
});
Expand Down

0 comments on commit fb98636

Please sign in to comment.