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.
es6-proxy
308
questions
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)));
...
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 ...
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 ...
-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 ...
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 ...
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(...
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) {
...
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);
...
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....". ...
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 ...
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 = {...
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;
...
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 ...
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, {
...
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 ...