-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving the render cycle API #118
Comments
@johan-gorter For the |
@jcfranco The VNode should not be modified, once it is passed to maquette. Maquette keeps a reference to this VNode to do a diff during the next run. The wrapUp phase should only modify the real DOM. The data that is used to render the VNode-tree may be modified during measure or wrapUp. For example: if a UI Component renders itself it may leave a |
@johan-gorter That makes sense, thanks for the explanation. |
We decided it would benefit everyone if we finish the other 3.0 issues first, so everyone can profit from these and to delay this issue bit, because this has more impact on codebases. |
You can write your whole application without doing anything with the render cycle. This is part of our philosophy of keeping things pure and simple. But you do need the render cycle if:
Every time a new screen is rendered, the following phases take place:
It is important to have a separate measure and wrapUp phase, because if multiple components were to measure and change the DOM in the same phase, unneeded reflows take place which would hurt performance.
Every time a render takes place, a new
RenderRun
object is created. All callbacks that are called during a render get a reference to theRenderRun
object as a parameter. TheRenderRun
has the following interface:The RenderRun can then be used as follows:
The following phases execute when a render takes place:
duringMeasure callbacks may be used to measure the DOM (getBoundingClientRect), but may not change the DOM.
duringWrapUp callbacks may change the DOM, but should not measure the DOM.
When all code uses the RenderRun object appropriately, all updates to the UI should never cause more than 2 reflows.
Migration path from afterCreate and afterUpdate:
AfterCreate can be replaced with
afterFirstRender
. Note that duringafterFirstRender
, the DOM Node is not attached to its parent. If theafterCreate
code needed this,afterFirstRender
can register code to run during measure or wrapUp.AfterUpdate can be replaced with
afterRender
. Note thatafterRender
also runs when the DOM node is first created and at that time it will not have a parent Node.This is one of our ideas for maquette 3
The text was updated successfully, but these errors were encountered: