Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Added `App.dom_ready_signal`. This signal is published one time when the App first finishes loading. Its purpose is to provide a simple way for widget libraries to do work only when the DOM is ready, since they cannot use the `Ready` event sent to the App class.

### Fixed

- Fixed `VERTICAL_BREAKPOINTS` doesn't work https://github.com/Textualize/textual/pull/5785
Expand Down
10 changes: 10 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,16 @@ def __init__(
perform work after the app has resumed.
"""

self.dom_ready_signal: Signal[App] = Signal(self, "dom-ready")
"""Signal that is published when the app is finished loading and the
DOM is ready. Note that this signal is only sent once when the app first loads.

This is intended for third-party widget libraries that need to perform
actions requiring a fully loaded DOM (such as querying for widgets) but
cannot override the App class's `on_ready` method. Subscribers must be
DOMNode instances (such as widgets or other DOM components).
"""

self.set_class(self.current_theme.dark, "-dark-mode")
self.set_class(not self.current_theme.dark, "-light-mode")

Expand Down
1 change: 1 addition & 0 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,7 @@ def _refresh_layout(self, size: Size | None = None, scroll: bool = False) -> Non
else:
self.app.post_message(events.Ready())
self.app._dom_ready = True
self.call_next(self.app.dom_ready_signal.publish, self.app)

async def _on_update(self, message: messages.Update) -> None:
message.stop()
Expand Down
Loading