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 ...
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.
...
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 ...
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 ...
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 ...
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) {
...
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);
// ...
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[]',
...
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]...
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.
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 ...
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 ...
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') {
...
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);
...
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 ...