Skip to content

Commit

Permalink
refactor(captp): align CTP_RESOLVE reject and resolve functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Oct 2, 2024
1 parent 7b8c677 commit dc37e6a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/captp/src/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ export const makeCapTP = (
}
// Set up promise listener to inform other side when this promise
// is fulfilled/broken
const resolved = result =>
send({
type: 'CTP_RESOLVE',
promiseID,
res: serialize(harden(result)),
});
const rejected = reason =>
send({
type: 'CTP_RESOLVE',
Expand All @@ -292,12 +298,7 @@ export const makeCapTP = (
});
E.when(
val,
result =>
send({
type: 'CTP_RESOLVE',
promiseID,
res: serialize(harden(result)),
}),
resolved,
rejected,
// Propagate internal errors as rejections.
).catch(rejected);
Expand Down

0 comments on commit dc37e6a

Please sign in to comment.