Take, for example, the following class, which uses WeakMaps for its private 
data:

```js
let _counter = new WeakMap();
let _action = new WeakMap();
class Countdown {
    constructor(counter, action) {
        _counter.set(this, counter);
        _action.set(this, action);
    }
    dec() {
        let counter = _counter.get(this);
        if (counter < 1) return;
        counter--;
        _counter.set(this, counter);
        if (counter === 0) {
            _action.get(this)();
        }
    }
}
```

If you wrap an instance of `Countdown` with a revocable Proxy (e.g. when it is 
returned by a method inside a membrane) that resets its private state, because 
its `this` changes.

Right? If yes then I’d expect that to cause problems for code that uses 
WeakMaps for private data.

-- 
Dr. Axel Rauschmayer
a...@rauschma.de
rauschma.de



_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to