Skip to content

Instantly share code, notes, and snippets.

@tarelli
Created February 10, 2015 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarelli/2c47ae47930e0571453c to your computer and use it in GitHub Desktop.
Save tarelli/2c47ae47930e0571453c to your computer and use it in GitHub Desktop.
Instance types meeting notes
var giovanni={}
giovanni.X=4
4
giovanni.Y=5
5
giovanni
Object {X: 4, Y: 5}
gioInstance.getType= function(){return this.target};
function (){return this.target}
gioInstance.getType();
Object {X: 4, Y: 5}
gioInstance.getType().X;
4
gioInstance.custom["X.T.Y.G.Padraig"]=9
VM2022:2 Uncaught TypeError: Cannot set property 'X.T.Y.G.Padraig' of
gioInstance.custom={};
Object {}
gioInstance.custom["X.T.Y.G.Padraig"]=9;
9
gioInstance
Object {target: Object, getType: function, custom: Object}custom: ObjectX.T.Y.G.Padraig: 9__proto__: ObjectgetType: function (){return this.target}target: ObjectX: 4Y: 5__proto__: Object__proto__: Object
gioInstance.getType().X;
4
entity={}
Object {}
entity.subentity={}
Object {}
entity
Object {subentity: Object}subentity: Object__proto__: Object
entity.subentity.giovanni=giovanni
Object {X: 4, Y: 5}
entity.subentity.giovanni.X
4
giovanni.X=666
666
entity.subentity.giovanni.X
666
giovanni
Object {X: 666, Y: 5}
POOL=new{}
VM2464:2 Uncaught TypeError: object is not a function
POOL=new{};
VM2465:2 Uncaught TypeError: object is not a function
POOL=\{};
VM2466:2 Uncaught SyntaxError: Unexpected token ILLEGAL
POOL={};
Object {}
POOL.giovanni={X:9,Y:4}
Object {X: 9, Y: 4}
entity.subentity.giovanni=POOL.giovanni
Object {X: 9, Y: 4}
entity.subentity.giovanni
Object {X: 9, Y: 4}
POOL.giovanni.X=23
23
entity.subentity.giovanni
Object {X: 23, Y: 4}
entity.subentity.giovanni2={}
Object {}
entity.subentity.giovanni2.type=POOL.giovanni
Object {X: 23, Y: 4}
entity.subentity.giovanni2.X=8
8
entity.subentity.giovanni2.Y=POOL.giovanni.Y
4
entity.subentity.giovanni2
Object {type: Object, X: 8, Y: 4}
entity.subentity
Object {giovanni: Object, giovanni2: Object}giovanni: ObjectX: 23Y: 4__proto__: Objectgiovanni2: ObjectX: 8Y: 4type: Object__proto__: Object__proto__: Object
POOL.giovanni.X=666
666
entity.subentity
Object {giovanni: Object, giovanni2: Object}giovanni: ObjectX: 666Y: 4__proto__: Objectgiovanni2: ObjectX: 8Y: 4type: Object__proto__: Object__proto__: Object
POOL.giovanni.Y=666
666
entity.subentity
Object {giovanni: Object, giovanni2: Object}giovanni: ObjectX: 666Y: 666__proto__: Objectgiovanni2: ObjectX: 8Y: 4type: Object__proto__: Object__proto__: Object
POOL
Object {giovanni: Object}giovanni: ObjectX: 666Y: 666__proto__: Object__proto__: Object
POOL.giovanni.X={value:666, instancepath:"giovanni.X"}
Object {value: 666, instancepath: "giovanni.X"}
POOL.giovanni.Y={value:222, instancepath:"giovanni.Y"}
Object {value: 222, instancepath: "giovanni.Y"}
//we receive POOL.giovanni
//we receive a reference node inside entity.subentity. the reference node points to POOL.giovanni
// we assign entity.subentity.giovanni to POOL.giovanni
//each aspect has its own pool
//what happens if I do entity.subentity.electrical.getModelTree()
entity.subentity.electrical={ModelTree:{}}
Object {ModelTree: Object}
entity.subentity.giovanni=
entity.subentity.giovanni2=
entity.subentity
Object {giovanni: , giovanni2: , electrical: Object}
delete entity.subentity.giovanni
true
delete entity.subentity.giovanni2
true
entity.subentity
Object {electrical: Object}electrical: Object__proto__: Object
entity.subentity.electrical.ModelTree
Object {}
entity.subentity2={electrical:{ModelTree:{}}}
Object {electrical: Object}
entity
Object {subentity: Object, subentity2: Object}subentity: Objectelectrical: ObjectModelTree: Object__proto__: Object__proto__: Object__proto__: Objectsubentity2: Objectelectrical: ObjectModelTree: Object__proto__: Object__proto__: Object__proto__: Object
//What happens if I do entity.subentity.electrical.getModelTree()?
//I will receive a type in the electrical pool
//The model tree will receive a pointer to POOL.electrical.giovanni
//What happens NOW if I do entity.subentity2.electrical.getModelTree()?
//the server won't send again the giovanni type as it was already sent
//the server would only send a reference node
//entity.electrical.getModelTree() will results in receiving all the reference node and no types
//entity.subentity.electrical.ModelTree.giovanni={reference:"POOL.giovanni"}
entity.subentity.electrical.ModelTree.giovanni={reference:"POOL.giovanni"}
Object {reference: "POOL.giovanni"}
//entity.subentity.electrical.ModelTree.giovanni.getType() would result in a call to the server since the type doesnt exist
//once we receive it we resolve all the references that point to it, replacing the referencenode to a javascript reference to the type
//would the same thing happen if we were to call getTypes() on POOL.electrical?
//btw POOL.electrical is of type AspectPool or AspectTypes or AspectDefinitions, a brand new Backbone model
//there are two scenarios, you could receive first the types and then the references or viceversa
//when you receive a reference you check if the type is in the pool or not
//by receive I mean that the server is sending me one, it could be inside a visualization tree or inside the response to a getModelTree
//if the type is in the pool you replace the referencenode with a pointer to the type
//if the type is not in the pool if it was a referencenode inside a getModeltree then you do nothing (unless the UI triggers something)
//if the type is not in the pool if it was a referencenode inside a visualization tree then you call getType automatically. when the client receives the type it puts it in the pool and it resolves automatically all the references that were pointing to it, i.e. it will replace the referencenode with pointers to the type that it just received
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment