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
1
vote
3
answers
123
views
How to always apply a method before executing another method via a proxy?
I have the following code where I want to invoke the instance method connect before proceeding with the invocation of every other instance method of the TelegramClient class. How can this be achieved ...
0
votes
0
answers
21
views
Typescript derives different types when a static method is called from inside or outside a class
Can someone help me explain the behavior of typescript in this example. I have no idea what is going on here. Why is childProxy1.foo not resolved while childProxy2.foo is resolved correctly? Why is ...
1
vote
1
answer
66
views
Is there a nicer way to handle isLoading checks in react? [closed]
In React we very often load data which is for some time undefined/null or some placeholder value. Now there are many ways to use loading skeletons, but in my project we have the skeletons rather low ...
0
votes
1
answer
64
views
A proxied JS child class assigns a wrong prototype to an instance
Some interesting case which I don't understand.
I proxy classes and extend a child class from a proxied base class.
When a child is constructed inside the construct trap for some reason a wrong ...
0
votes
0
answers
31
views
How to get data from a Proxy Array in Javascript? [duplicate]
I am making a request via Axios to a REST API made in LARAVEL 9, this is my Backend that sends them via JSON to the frontend.
public function index()
{
try {
$marcas = DB::table('marca')-&...
2
votes
2
answers
519
views
ES6 Proxy to return an iterable array
I need to exercise some code in data mapping functions. For this, I need a proxy that returns an iterable array with one element (itself; an iterable array) when any property is requested. This will ...
0
votes
2
answers
57
views
JavaScript proxies : aggregate notifications after array sort
I would like to find a way to get only one notification after an array sort
Is there a way? Thank you
const callback = function () {
console.log (...arguments)
}
const array = [2,1]
const handler = {...
-1
votes
1
answer
52
views
Why is Proxy being called for nested elements?
I'm attempting to abstract some Cypress methods into a helper object using getters.
The intended behavior is that I can do something like this:
todoApp.todoPage.todoApp.main.rows.row
.first()....
1
vote
3
answers
75
views
How can I detect changes to arbitrary private members with an ES6 proxy in Javascript?
I am working on building a 2D renderer with the Javascript canvas API, and I am trying to improve performance by skipping renders when no changes to the state of any renderable objects have occurred.
...
0
votes
1
answer
616
views
Typescript: function should return proxy object of generic object type
The following function should create a proxy object with a specific handler, but typescript is throwing a type error when I try it that way.
function createProxiedObject<T extends object>(obj: T)...
-1
votes
1
answer
207
views
Javascript construct trap not working in class returning proxy
I am trying to create a little javascript two way form binder using proxies. I am stuck on how I can intercept 'new' calls. I use a 'construct' trap but it doesn't fire. Here is my code, I have ...
-1
votes
2
answers
339
views
How to proxy Function.prototype?
I tried to proxy Function.prototype.
I created a new Proxy and rewrote the toString method, however console.log('cas') doesn't work, why?
Function.prototype = new Proxy(Function.prototype, {
get: ...
1
vote
1
answer
66
views
For an instance field which is an array value, how does one handle additional tasks whenever the array mutates by e.g. pushing into or splicing it?
The set accessor does not take place whenever one does mutate the Crumbs class property value by e.g pushing into it.
I'm trying to create a class property via set syntax which I expect to handle an ...
1
vote
1
answer
279
views
why are target and receiver not the same in this javascript proxy?
I am working with JavaScript Proxy and do not understand why the target and the receiver are different in both the get() and set() traps. They appear to be the same (based on console logging). The ...
1
vote
1
answer
233
views
Implement a dynamic lazy proxy collection class on typescript
I'm trying to implement a lazy database connection collection in typescript. I'm creating a class called DatabaseCollection and my idea is to use a proxy to lazy load the connections (I'm using knex ...