Skip to content
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

feat(widgets): Rename StatefulWidget::render to render_stateful #1183

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

joshka
Copy link
Member

@joshka joshka commented Jun 17, 2024

This change renames the StatefulWidget::render method to
render_stateful to avoid conflicts with the Widget::render method.

Often both the Widget and StatefulWidget traits are in scope, and
when calling the render method on a StatefulWidget the compiler
cannot determine which trait to use. This change resolves that issue by
renaming the StatefulWidget::render method to render_stateful.

The StatefulWidget::render method is still available, but it is
deprecated. A default implementation of render_stateful is provided
that calls the deprecated render method.

Callers should update their code to use render_stateful instead of
render.
implementors of the StatefulWidget trait should update their
implementations to implement render_stateful instead of render, and
provide an implementation of render that calls render_stateful.

This change is non-breaking. The deprecated render method will be
removed in a future release of Ratatui (likely 0.29.0).

Addresses part of a problem raised in
#996

This change renames the `StatefulWidget::render` method to
`render_stateful` to avoid conflicts with the `Widget::render` method.

Often both the `Widget` and `StatefulWidget` traits are in scope, and
when calling the `render` method on a `StatefulWidget` the compiler
cannot determine which trait to use. This change resolves that issue by
renaming the `StatefulWidget::render` method to `render_stateful`.

The `StatefulWidget::render` method is still available, but it is
deprecated. A default implementation of `render_stateful` is provided
that calls the deprecated `render` method.

Callers should update their code to use `render_stateful` instead of
`render`.
implementors of the `StatefulWidget` trait should update their
implementations to implement `render_stateful` instead of `render`, and
provide an implementation of `render` that calls `render_stateful`.

This change is non-breaking. The deprecated `render` method will be
removed in a future release of Ratatui (likely 0.29.0).

Addresses part of a problem raised in
<#996>
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 78.94737% with 8 lines in your changes missing coverage. Please review.

Project coverage is 94.2%. Comparing base (4bfdc15) to head (5c66a94).
Report is 7 commits behind head on main.

Files Patch % Lines
src/widgets/list.rs 71.4% 4 Missing ⚠️
src/widgets/table/table.rs 75.0% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1183     +/-   ##
=======================================
- Coverage   94.3%   94.2%   -0.1%     
=======================================
  Files         60      60             
  Lines      14679   14710     +31     
=======================================
+ Hits       13843   13862     +19     
- Misses       836     848     +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kdheepak kdheepak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the other PR, I think we could do render_with_state() instead, but I'm fine with render_stateful(). Again, worth checking in with other maintainers for a second opinion.

@joshka
Copy link
Member Author

joshka commented Jun 17, 2024

Similar to the other PR, I think we could do render_with_state() instead, but I'm fine with render_stateful(). Again, worth checking in with other maintainers for a second opinion.

likewise - I'm 55/45 on stateful vs with_state here too.

@joshka
Copy link
Member Author

joshka commented Jun 19, 2024

Holding for resolution of discussion at https://forum.ratatui.rs/t/naming-render-traits-methods/68

@joshka joshka added Status: Pending Waiting on clarification / more information from submitter Type: Maintenance Updates to dependencies / CI / lints / etc. labels Jun 19, 2024
@joshka joshka self-assigned this Jun 20, 2024
@joshka joshka added the Status: On Hold Not actively being worked on for now due to time / other constraints label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: On Hold Not actively being worked on for now due to time / other constraints Status: Pending Waiting on clarification / more information from submitter Type: Maintenance Updates to dependencies / CI / lints / etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants