3 ms·
Consider using a `Proxy` object. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy https://developer.mozilla.org/en-US/doc
by lemevi 11y ago
Consider using a `Proxy` object.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- bcherny 11y agomaybe chrome will support this soon...
- AnkhMorporkian 11y agoProxies are brilliant. I used one to create an promise based RPC system that allows you to call any method you want. So before proxies, we used to do it as: await server.rpc.run("methodName", [argumentOne, argumentTwo]) Now, we just do: await server.rpc.methodName(one, two) The proxy traps that method call and returns a promise that runs that on the server. It's very slick and has made our code a lot more readable.