Skip to content

Add a returning promises section #69

@marcoscaceres

Description

@marcoscaceres

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions