X Tutup
Skip to content

Naming convention for Promise. #848

@namse

Description

@namse

I'm so confused. In general case, we name the function like 'verb-what' like getItem, setQuantity, request, etc.

On case of GET functions, we can guess what type or what kind of values will return.

How about the function which return promise witch will return some other values?
Or, a just Promise. How should I name that?

For example, there are a promise which will query the user's name from database, should the promise name be getName ? or getNamePromise?

In first case(getName), other co-worker could misguess that this function will return name synchronously, so he could directly assign the variables value, like this,

const name = getName();
console.log(name) // Promise {[[PromiseStatus]]: "pending"....}

it doesn't seem good to add 'Async' suffix (getNameAsync).
adding prefix 'promise' ( promiseGetName ) neither.

promiseGettingName
gettingName
...
hmm....

Any good idea for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup