[Question] Why not get a promise as a param instead of a function? #8
Answered
by
kettanaito
eduardosada
asked this question in
Q&A
-
Why is this better? const [error, user] = await until(() => fetchUser(id)) instead of this? const [error, user] = await until(fetchUser(id)) |
Beta Was this translation helpful? Give feedback.
Answered by
kettanaito
May 12, 2021
Replies: 2 comments 1 reply
-
Could probably work, there are a bunch of alternatives that do that:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I like how passing a function creates a new scope in which a promise is created, as opposed to accepting a promise potentially created elsewhere. I don't have any hard opinion on this, so if you think an alternative call signature makes more sense, I wouldn't mind changing it. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kettanaito
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like how passing a function creates a new scope in which a promise is created, as opposed to accepting a promise potentially created elsewhere. I don't have any hard opinion on this, so if you think an alternative call signature makes more sense, I wouldn't mind changing it.