Refactoring how _position is called to be promise-based

The render method now returns a promise. Once this promise is resolved,
the _position method for that node will be called (if applicable). This
promise must be resolved only after all subordinate nodes have completed
their render phase (the promise returned by subordinate node's render
method has resolved). Node that do not have subordinates can return the
result of calling terminalRender, and proxied renders only need to
return the result of calling proxy.

With this change, it is no longer necessary to explicitly position
subordinate nodes. They will already be positioned once their render
promise is resolved.
This commit is contained in:
Jeff Avallone
2014-12-13 09:09:58 -05:00
parent bc84f68250
commit 773fd5c1a6
12 changed files with 64 additions and 73 deletions
+4 -5
View File
@@ -1,4 +1,5 @@
import _ from 'lodash';
import Q from 'q';
import Base from './base.js';
export default _.extend({}, Base, {
@@ -9,14 +10,12 @@ export default _.extend({}, Base, {
this.partContainer = this.container.group();
_.each(this.parts.elements, (part => {
part.render(this.partContainer.group());
}).bind(this));
return Q.all(_.map(this.parts.elements, (part => {
return part.render(this.partContainer.group());
}).bind(this)));
},
_position() {
_.invoke(this.parts.elements, 'position');
this.spaceVertically(this.parts.elements, {
padding: 5
});