ES6 Proxy Function Call Trap

Edwin Reynoso eorroe at gmail.com
Tue Jun 9 08:44:56 UTC 2015


Alright first I'll say I'm using FF to test because FF supports proxies,
and I really don't know how to use Reflect and how it works yet. FF as well
does not support Reflect right now. Therefore I'll look into that.

So from [this source](
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply#Interceptions)
it seems that it would only work if the actual proxy is invoked as a
function?

Take a look at the example in that link as well.

Now I'm not sure if Reflect changes that somehow.

**BTW** When I ran the code, I didn't get an `Error` saying that `Reflect`
is not defined I got:

`TypeError: people.logFullName is not a function`

So I don't think that worked.

On Tue, Jun 9, 2015 at 3:39 AM, Claude Pache <claude.pache at gmail.com> wrote:

>
> Le 9 juin 2015 à 07:58, Edwin Reynoso <eorroe at gmail.com> a écrit :
>
>
> **Or does someone know how to do what I'm trying to accomplish**
>
>
> Maybe the following code goes in the direction of what you want?
>
> ```js
> var people = new Proxy([new Person('Edwin', 'Reynoso'), new Person('That',
> 'Guy')], {
> get(target, property) {
> if (target[property] !== undefined)
> return target[property];
> var arr = [];
> for (var person of target) arr.push(person[property]);
> return new Proxy(arr, {
> apply(target, thisArg, args) {
> return target.map(item => Reflect.apply(item, thisArg, args))
> }
> })
> }
> });
> ```
>
> About your proposal, I recall that, at some point in the history of ES6
> draft, there was an `[[Invoke]]` MOP, and a corresponding `invoke` trap for
> proxies, that were finally eliminated.
>
> —Claude
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150609/a3ad9f6b/attachment-0001.html>


More information about the es-discuss mailing list