In fix(widgets)!: rename `StatefulWidgetRef::render_ref` to `render_stateful_ref` by joshka · Pull Request #1184 · ratatui-org/ratatui · GitHub @kdheepak wrote:
I have a preference for renaming these new trait names (the ones that are unstable) to
Render
andRenderWithState
and then changing the names of the trait methods to match accordingly.The disadvantage is that it would break from convention with the
Widget
andStatefulWidget
traits. The advantage is that it is more consistent and clear (imo).And I can see a world where everyone moves to using these new traits, and we deprecate the old ones and remove them eventually (a few years later?).
In general I’m in agreement with the Render/RenderWithState naming, but I have some concerns about taking that track at least in the short term.
My initial concerns about this naming approach are that:
- The concept of widgets is a useful one. It enables talking about widgets as concrete things “the paragraph widget” rather than as “Paragraph’s implementation of the Render trait”. The ability to talk about and document things easily seems pretty important to me.
- Keeping consistent naming with what we have already makes it easy for users to see the concepts as linked. I.e. the
WidgetRef
trait is the same as theWidget
trait, but takes a ref instead of consuming self. This sort of discoverability for existing users and newer users seems important. - Using the newer names for this puts us on the hook to document these concepts well and talk about how they’re different and why from the existing code. I don’t relish the thought of updating all the documentation for this sort of churn (it would be fairly tedious to review all the places where this sort of thing impacts our docs).
- The additional work to design / document / communicate the Render/RenderWithState trait stuff would delay stuff which we could really do with having now. (The impetus of this is wanting to disambiguate the Widget/Ref render method from the StatefulWidget/Ref render methods more easily in code.
That said, the downsides of the Widget trait in general are that it’s really anemic:
- it only handles rendering
- it does not handle layout, events, ui state (active/hover), interaction, focus, context, frame count, …
It would be really nice to eventually have widgets be a solid trait to put all this (instead of this stuff being implemented piecemeal as Component
traits that seem to pop up in various apps).
Taking note of those points, I lean towards continuing with the WidgetRef
/ StatefulWidgetRef
naming of the traits. I’d suggest that we defer the larger change to some later Ratatui revision where we properly design some of these things from scratch.