0

I have been searching high and low for any straightforward answer to this question and, sadly, must now come to the internet community at large and ask a question.

Simply put, I would like to know if ES2015 Proxy handler objects are restricted to defining solely those traps defined in the specification or if any trap may be defined?

Secondly, I have been unable to locate any recent tutorials, posts, or material released (save for the specs or references) on Proxies, Reflection, and Symbols and wanted to know if there were any resources any knew of that are caught up with the current state of the spec? Again, I am aware that both the spec and websites that maintain a JavaScript language reference are up to date, but I am looking for more colloquial explanations or tutorials.

Thank you, in advance.

As a bonus round, does anyone have any uses or design patterns that are not already discussed in the literature for Proxies, Reflection, and/or Symbols?

user3840170
  • 26,597
  • 4
  • 30
  • 62
Goggerz
  • 9
  • 1
  • 2
    What do you mean by "any trap"? The ones proxy supports are the ones the language exposes. – loganfsmyth May 04 '16 at 22:13
  • So, those traps defined in the specification are the only ones available to define on a handler, correct? I couldn't, for instance, define a 'access' trap that performs all access logic for an object? – Goggerz May 04 '16 at 22:27
  • That's what I'm trying to get a sense of. What access are you looking for that isn't covered by the current traps? – loganfsmyth May 04 '16 at 23:03
  • Oh, no, I don't have anything entirely specific in mind. Just trying to get a grasp on Proxy as a concept. Hence, my question. I do not see any need for *more* access, I am more curious about redefining the vehicle by which that access is granted, namely the methods defined and implemented. Instead of say, a get and a set and so forth, having a single access() method that could take a 'verb' argument and possibly an options object or some such device to convey the rest of the data to create a more simplistic interface to an object. That is what I am curious about. – Goggerz May 04 '16 at 23:55
  • @Goggerz: A proxy handler is just an objects and can have as many methods as you want, and those methods can call each other. But the proxy will only call those methods that are defined in the spec, and nothing else. You can of course make `get`,`set` etc call your `access` method, but you'll have to do that explicitly. – Bergi Jun 09 '16 at 13:54

0 Answers0