Slide 24
Slide 24 text
Let’s mix!
var proxy = new Proxy({}, {
get(target, name) {
var chain = { type: 'get', target, name };
if (name === 'then') {
return askMainThread(chain);
}
return new Proxy(chain, this);
}
});
proxy.a; // {type: 'get', target: {}, name: 'a'}
proxy.a.b; // {type: 'get', target: {…, name: 'a'}, name: 'b'}
await proxy.a.b.c; // 'a.b.c'