-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Interesting discussion came up internally at Mozilla around what should happen when you have a .method() that returns a promise. We were discussing annotating methods with [NewObject] for promise returning .method()... question that came up was, should a promise returning method always return a newly created promise? Or are there cases where it makes sense to return the same Promise, representing some ongoing operation.
For example:
const p1 = Tasks.doTask("some-id");
const p2 = Tasks.doTask("some-id");
await Promise.all([p1, p2]);
const p3 = Tasks.doTask("some-id"); // obviously a new promise!
As p1 and p2 represent the same task, would p1 === p2 or p1 !== p2? My personal preference is for always getting new promises object, but some guidance would be great.
Metadata
Metadata
Assignees
Labels
No labels