TNG-Hooks
TNG-Hooks copied to clipboard
Provides React-inspired 'hooks' like useState(..) for stand-alone functions
I'm supposing hooks is pronounced /hʊks/ as usual but now I'm not certain how to pronounce TNG, is that notation supposed to be IPA or is it some more obscure...
**[Updated with suggestions from down-thread]** # Proposal: External TNG Hooks-Context ~~Going along with some of the ideas proposed around hooks being designed as "algebraic effects",~~ Inspired by the idea of...
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...
This hook is basically exactly like `useEffect(..)` except that it specifically defers its behavior **asynchronously** until the render frame (via `requestAnimationFrame(..)`).
For posterity sake, let's clarify that [throttling and debouncing are in fact distinct](https://codeburst.io/throttling-and-debouncing-in-javascript-646d076d0a44), while still clearly being related. But both of these seem like worthwhile decorative hooks to add, which...
I have an idea for a couple of features that I think would make debugging and testing of hooks much better. Want to sketch them out here and get feedback....
The `useDeferred()` hook creates and stores in a state slot (via `useState(..)`) an object, commonly called a deferred, which is a promise and also its `resolve(..)` / `reject(..)` capabilities. ```js...