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.

es6-proxy
87 questions with no upvoted or accepted answers
9 votes
1 answer
280 views

Is using `with` statement with Proxies a bad practice?

First of all, I want to clarify, I know that with is deprecated, and using it is generally a bad practice. However, my question is about a special case: using a special Proxy object as the parameter ...
FZs's user avatar
  • 18.2k
8 votes
2 answers
2k views

How to get deleted or inserted item from proxy array?

I am trying to detect changes in an array of objects using JavaScript proxies. Problem: Any time there is a change in array like deletion or insertion, i want to get that deleted or inserted item. ...
Johar Zaman's user avatar
  • 2,043
6 votes
1 answer
612 views

dispatchEvent(new Proxy(event, {}) does not work

I'm working on an app which uses events. The modules of the app execute in separate containers and I thought about using Proxy to tame the events that are fired. However, I cannot seem to be able to ...
user253530's user avatar
  • 2,581
5 votes
0 answers
2k views

How to create a proxy for HTMLELement

Question How to create a proxy for browser native DOM object? Background I want to intercept the settings for the element style. So I create a proxy for the DOM object. However, it causes error ...
Ryths Xia's user avatar
4 votes
0 answers
1k views

Proxying localStorage for dynamic object insertion

I want to proxy localStorage setters and getters to parse objects and save them to storage on assignment like I use a regular object. Pretty straight forward when saving single KV items but ...
Vadim Brook's user avatar
4 votes
1 answer
1k views

Unable to use ES6 proxy with window.document object

I have written some code that is supposed to watch for modifications to document.cookie and print to console whenever that happens. var handler = { set: function(target, property, value) { ...
xrisk's user avatar
  • 3,868
4 votes
1 answer
182 views

Proxying a recursive function

Imagine a simple recursive function, which we are trying to wrap in order to instrument input and output. // A simple recursive function. const count = n => n && 1 + count(n-1); // ...
user avatar
3 votes
0 answers
4k views

How to get plain javascript array from realm object proxy list?

Scenario: For ex, you define a schema in realm-js as: export const businessSchema = { name: 'Business', primaryKey: 'id', properties: { id: 'int', number_of_stores_in_cities: 'int[]', ...
RandomEli's user avatar
  • 1,527
3 votes
0 answers
4k views

ES6 Nested Proxy for Get on Frozen Object

I'm trying to deeply proxy the properties of a frozen object: const a = Object.freeze([{ prop: 1 }]) const proxy = new Proxy(a, { get(target, property) { return new Proxy(target[property]...
Matt Bierner's user avatar
3 votes
1 answer
268 views

What is the alternative for enumerate() for JavaScript Proxy to trap for ... in

What is the alternative for the enumerate() for JavaScript Proxy to trap for ... in Since enumerate() is deprecated.
faressoft's user avatar
  • 19.5k
2 votes
1 answer
260 views

Remote objects using web sockets

Is there a library which allows me to call remote objects by web sockets? My target is to able to use an object like any other object (set/get properties on it, call methods) but the object would ...
Don Box's user avatar
  • 3,306
2 votes
0 answers
242 views

run cleanups automatically when a block variable gets out of scope in javascript

the answer to this question will probably be "it cannot be done with out writing a custom javaScript parser" but here i go: while developing some lightweight scripting tool i ran into a need to do ...
tal shachar's user avatar
2 votes
1 answer
329 views

how to make Proxy's trap asyncronous?

Let's say we have an object: const obj = { element } and a Proxy with "asyncronous trap": const proxy = new Proxy( obj, { get: async function(obj, prop) { if(prop === 'element') { ...
Asker's user avatar
  • 71
2 votes
1 answer
754 views

Trace method calls with javascript proxy

var handler1 = { get:function(target,key){ if (typeof target[key] == "function"){ var method = Reflect.get(target, key); return method.bind(target); ...
Ayush Goel's user avatar
2 votes
0 answers
184 views

ES6 Proxies in Angular Template

I am using RxDB (essentially a wrapper for pouchdb using rxjs), in my Angular application. Each document in the database (called an RxDocument) is a ES6 Proxy. For instance, I could have and ...
Derek Brown's user avatar
  • 4,370

15 30 50 per page
1
2 3 4 5 6