Merge pull request #838 from Textualize/anim-fix

Initialize reactive variables earlier
This commit is contained in:
Will McGugan
2022-10-06 14:04:31 +01:00
committed by GitHub
3 changed files with 3 additions and 2 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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: