I'm trying to Proxy a Promise in native Firefox (and using Babel).
var prom = new Promise(function(resolve, reject){resolve(42)});
var promProxy = new Proxy(prom, {});
promProxy.then(function(response){console.log(response)});
This doesn't work, I get 'TypeError: 'then' called on an object that does not implement interface Promise.'
You need to have your handler implement the get() trap and return the bound version of
prom.then
Note that if you simply want to proxy all accessors, the
get
function would look like this:bind
will ensure the function won't be incorrectly called when you're dealing with Native objects such as Promises, or the console.EDIT: In some instances browsers / node will have an outdated version of Proxies, in which case you'll want to use harmony-reflect to bring it up to date.