4 ms·
That is really interesting, I'm building something with Proxies for any Type and async function proxified worked for me. Mind if I hit you up for a chat?
by diegorbaquero 8y ago
That is really interesting, I'm building something with Proxies for any Type and async function proxified worked for me. Mind if I hit you up for a chat?
- kozhevnikov 8y agoSure. I mean if you have an async function that returns another function (so it actually returns a promise of a function because it's async) proxy of the original function will call apply handler when invoked, but proxy of the return value will not because it's actually not a function but an object (a promise of a function) and as it turned out proxied objects do not call apply handler when invoked (even if it's defined) but throw an exception. const handler = { apply: () => { console.log('ok') } }; const foo = new Proxy(() => {}, handler); const bar = new Proxy({}, handler); > foo() < ok > bar() < VM313:1 Uncaught TypeError: bar is not a function at <anonymous>:1:1