🚧 Working Map proxy
This commit is contained in:
parent
24e7d413f5
commit
abca8a809d
4 changed files with 27 additions and 9 deletions
20
lib/part.ts
20
lib/part.ts
|
@ -4,10 +4,27 @@ import { Snippet } from './snippet'
|
|||
import { Attributes } from './attributes'
|
||||
import { PointList } from './pointlist'
|
||||
|
||||
var pointProxy: any = {
|
||||
id: 'test',
|
||||
get: function(points, key: string, proxy: ProxyHandler<Map<any, any>>): Point {
|
||||
console.log(`getting ${key}`);
|
||||
return points.get(key);
|
||||
},
|
||||
set: function(points: Map<string, Point>, key: string, point: Point, proxy: ProxyHandler<Map<any, any>>) {
|
||||
console.log(arguments);
|
||||
console.log(`Args above. Setting ${key} to`, point);
|
||||
point.attributes.add('data-key', key);
|
||||
point.attributes.add('data-part', this.id);
|
||||
points.set(key, point);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export class Part {
|
||||
id: string;
|
||||
render: boolean;
|
||||
points: PointList = new PointList();
|
||||
points = new Proxy(new Map(), pointProxy);
|
||||
paths: { [index: string]: Path; } = {};
|
||||
snippets: { [index: string]: Snippet; } = {};
|
||||
attributes = new Attributes();
|
||||
|
@ -16,6 +33,7 @@ export class Part {
|
|||
constructor(id: string) {
|
||||
this.id = id;
|
||||
this.render = (id.substr(0,1) === '_') ? false : true;
|
||||
this.points = new Proxy(new Map(), pointProxy);
|
||||
this.points.origin = new Point(0,0);
|
||||
|
||||
return this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue