You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As #2 (comment) says, the plenary today was slightly in favor of once functions returning undefined every time (and ignoring arguments), so that all function calls remain idempotent. Any sync error thrown by the first call would only be thrown by the first call once and no more times after that. If the return value is needed, the developer would have to use a memoize function instead (which I also plan to propose).
However, returning undefined means that the promises returned by async functions are lost—which also means that rejections cannot be detected.
Should we have a onceAsync function? Is it within scope of this proposal?
If const f = onceAsync(Promise.resolve); then [f(0), f(1), f(2)] could return [p, p, p], where p is the same promise that resolves to undefined, and arguments are ignored.
As #2 (comment) says, the plenary today was slightly in favor of once functions returning undefined every time (and ignoring arguments), so that all function calls remain idempotent. Any sync error thrown by the first call would only be thrown by the first call once and no more times after that. If the return value is needed, the developer would have to use a
memoize
function instead (which I also plan to propose).However, returning undefined means that the promises returned by async functions are lost—which also means that rejections cannot be detected.
Should we have a onceAsync function? Is it within scope of this proposal?
If
const f = onceAsync(Promise.resolve);
then[f(0), f(1), f(2)]
could return[p, p, p]
, wherep
is the same promise that resolves toundefined
, and arguments are ignored.(Spun off from #7.)
The text was updated successfully, but these errors were encountered: