Skip to main content

Questions tagged [es6-proxy]

The ES2015 Proxy object allows the creation of objects with custom dispatch semantics for operations like property lookup, assignment, enumeration, invocation as a function or constructor.

3 votes
1 answer
2k views

How can I reliably convert a proxy to a standard object?

I'm working with events in JavaScript, and often the event is a proxy object. When debugging I can usually use this to get a copy of the object. console.log(JSON.parse(JSON.stringify(event.detail))); ...
Chuck's user avatar
  • 4,800
1 vote
1 answer
490 views

Why is `this` undefined in a constructor defined Proxy method for a derived class?

I attempting to overwrite/proxy a function from a library class. I've done this by extending the class and defining a Proxy object over the method. Alas, like in this question, the this object in the ...
Lee's user avatar
  • 30.6k
1 vote
0 answers
275 views

Proxy js object: where are defined arguments when calling a function using Reflect.get()

Trying to understand the internals of Proxy and Reflect built-in objects, I've reached - IMO - an interesting "how does this even work" point: Let's say I want to wrap into a Proxy this ...
Manu Artero's user avatar
  • 10.1k
-1 votes
2 answers
4k views

Get array in [[target]] from proxy

How can i get this number from productCount.value (screenshot)? Trying productCount.value.array, but i will get again proxy - [[target]] - array Edit 1: If i use productCount.value.array[0] i will get ...
Jessika's user avatar
  • 27
1 vote
0 answers
63 views

IntersectionObserver superseded by Proxy?

It makes sense to me that IntersectionObserver is preferred to adding scroll-based event listeners these days. Great. However, I read here and here that a Proxy offers a more desirable way to do this ...
ACJ's user avatar
  • 13
0 votes
0 answers
50 views

In Javascript, is it possible to proxy 'this' within a constructor, without editing the constructor

Imagine I have the following Javascript class: class C { constructor() { this.foo = "bar" } } I have proxied C so I can intercept construction of C: const handler = { construct(...
ebdavis's user avatar
  • 105
0 votes
1 answer
62 views

How to measure time of function using js proxy

I would like to measure time of my all function in my class Foo. My code is: class Foo { constructor() { return new Proxy(this, { get(target, prop, receiver) { ...
teteyi3241's user avatar
0 votes
1 answer
230 views

Change value (wrap) of Reflect function in Proxy handler

I have this; function traceMethodCalls(obj) { console.log('wrapping brain API') const handler = { get(target, propKey, receiver) { console.log('GET', propKey); ...
Curcuma_'s user avatar
  • 871
3 votes
1 answer
2k views

Can a Proxy really provide access to private fields of a class?

I'm reading the documentation here, and it seems to imply that even for private fields, it would be possible to access them via a Proxy. See the blurb that starts with "....To fix this....". ...
Kenneth Stephen's user avatar
2 votes
2 answers
834 views

javascript Proxy of function apply trap gives no access to the receiver Proxy

When I have a Proxy the get and set traps both provide access to the underlying target Object as well as the Proxy receiver of the initial access request. This is good, because for some "pseudo ...
Gunther Schadow's user avatar
1 vote
1 answer
640 views

Class Reactivity with Proxy does not work as expected in Vue 3

I have a Class with a proxy-based object, the set() method changes another property of the same class, everything works fine if I run the code only in JS/TS. class Form { errors = [] values = {...
Yung Silva's user avatar
  • 1,432
0 votes
0 answers
11 views

How can I get parent class scope in a Proxy in a class [duplicate]

class dataset { __data__={}; __actions__ = {}; __data__ = new Proxy(this.__data__,{ set(target,prop,val){ this.__actions__[prop]?this.__actions__[prop]():''; target[prop]=val; ...
Satyam Bharti's user avatar
0 votes
0 answers
103 views

Proxy pattern in Javascript without inbuilt Proxy class

I want to intercept requests to Object A and log some message and forward the request back to Object A Es6 proxies and reflect would be a good use case for this, but I’ll be taking a huge performance ...
Eshwar NE's user avatar
  • 113
2 votes
1 answer
5k views

Uncaught TypeError: proxy set handler returned false for property '"length"'

I started testing the following proxy pattern, and got the titled error when using the .splice() method. class A extends Array { constructor(...x) { super(...x) return new Proxy(this, { ...
hardstuck's user avatar
1 vote
1 answer
250 views

ES6 Proxies for location.pathname changes

Is it possible to use ES6 Proxies to track changes of location.pathname? As far as I know, Proxies can be used for objects, and location.pathname is an object, right? If the answer is yes, can someone ...
Paul Berger's user avatar

15 30 50 per page
1 2 3
4
5
21