roact icon indicating copy to clipboard operation
roact copied to clipboard

Signal when a component is rendered

Open AmaranthineCodices opened this issue 7 years ago • 1 comments
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. Is nil otherwise.
  • newHandle: The new handle. This is the only handle for when the component is mounted, and nil when the component is unmounted.
  • renderType: One of the three values of RenderType above, corresponding to the correct kind of render.

AmaranthineCodices avatar May 14 '18 13:05 AmaranthineCodices

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.

LPGhatguy avatar May 14 '18 20:05 LPGhatguy