mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #838 from Textualize/anim-fix
Initialize reactive variables earlier
This commit is contained in:
@@ -1100,6 +1100,7 @@ class App(Generic[ReturnType], DOMNode):
|
||||
mount_event = events.Mount(sender=self)
|
||||
await self._dispatch_message(mount_event)
|
||||
|
||||
Reactive.initialize_object(self)
|
||||
self.title = self._title
|
||||
self.stylesheet.update(self)
|
||||
self.refresh()
|
||||
|
||||
@@ -286,6 +286,7 @@ class MessagePump(metaclass=MessagePumpMeta):
|
||||
|
||||
def _start_messages(self) -> None:
|
||||
"""Start messages task."""
|
||||
Reactive.initialize_object(self)
|
||||
self._task = asyncio.create_task(self._process_messages())
|
||||
|
||||
async def _process_messages(self) -> None:
|
||||
@@ -303,7 +304,6 @@ class MessagePump(metaclass=MessagePumpMeta):
|
||||
"""Process messages until the queue is closed."""
|
||||
_rich_traceback_guard = True
|
||||
|
||||
await Reactive.initialize_object(self)
|
||||
while not self._closed:
|
||||
try:
|
||||
message = await self._get_message()
|
||||
|
||||
@@ -83,7 +83,7 @@ class Reactive(Generic[ReactiveType]):
|
||||
return cls(default, layout=False, repaint=False, init=True)
|
||||
|
||||
@classmethod
|
||||
async def initialize_object(cls, obj: object) -> None:
|
||||
def initialize_object(cls, obj: object) -> None:
|
||||
"""Call any watchers / computes for the first time.
|
||||
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user