Closed wilsonpage closed 11 years ago
layout
.set(1, orange)
.set(2, apple);
layout
.slot(1, orange)
.slot(2, apple);
layout
.add(orange)
.add(apple);
Each module could store a reference to it's slot
but the canonical reference would be held on the parent.
That way when we do apple.destroy()
we can still trace back the reference on the parent so that it can be removed.
It is probably sensible to support both methods. I think to build in the support for this each parent must also have a hash of children by slot.
layout._childhash;
//=> { 1: apple, 2: orange }
layout.children;
//=> [ apple, orange ]
Adding:
var apple = new Apple({ slot: 1 });
layout.add(apple);
// same as
var apple = new Apple();
layout.slot(1, apple);
// same as
var layout = new Layout({
children: [
{
module: 'apple',
slot: 1
}
]
});
// same as
var layout = new Layout({
children: {
1: {
module: 'apple'
}
}
});
We have to keep the add
method to support 'list' layouts as well as 'slot' layouts. This is because list layouts (think TODO list) don't have slots, they jsut need to print all the children in the correct order.
This has been implemented in a backwards compatible way. We need to update the docs to show how slots should be used.
Does it make sense for child modules to decide their own location? This seems to go against our concept of top down modularity.
could become...
Now modules are no longer aware of their location.
layout.children
is no longer an array, but an object. Keys mapping directly to slots on that view.Again, just a thought I wanted to to get down for future discussion.