This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
Feature: usePromisify(..)
#16
Labels
usePromisify(..)
#16
The
usePromisify(..)
hook would wrap/lift a callback-expecting function as a promise-returning function. It would expect callback-last, and err-first-callback.Similar to Node's
util.promisify(..)
, this hook would allow overriding of that assumption via a Symbol added to the function in question, to define its own promisified version. In that case, theusePromisify(..)
hook would just return that value and do nothing else.The benefits of this as a hook:
Since it would store the promisified version in a state slot, it allows you to promisify inline function expressions safely without unnecessary work (the wrapping would only happen the first time).
Just like
useMemo(..)
anduseEffect(..)
, we'd allow optional guards to override and re-define, if closure was required.It doesn't require polluting the outer/global namespace with a promisified version of the function. In other words, it allows you to only locally create a promisified override without affecting the rest of the program.
The text was updated successfully, but these errors were encountered: