roact
roact copied to clipboard
Signal when a component is rendered
trafficstars
Continuing on my project for a Roact explorer in #89, I'd like to be able to get some sort of signal from Roact when a component renders. This would let me update the explorer only when necessary, without resorting to polling the active handles.
This would fire when:
- A new component is mounted
- An existing component is re-rendered
- A component is unmounted
Proposed API:
Signal Roact.Debug.onRender(oldHandle, newHandle, renderType)
Roact.Debug.RenderType = {
Mount = 0,
Reconcile = 1,
Unmount = 2,
}
onRender is fired when any of the above events happen. Its listeners receive three arguments:
oldHandle: The old handle, if applicable. Isnilotherwise.newHandle: The new handle. This is the only handle for when the component is mounted, andnilwhen the component is unmounted.renderType: One of the three values ofRenderTypeabove, corresponding to the correct kind of render.
Like I mentioned in #89, this would probably be facilitated by a 'tree root' object, which is where work scheduling will happen in the new async renderer.