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)
|
mount_event = events.Mount(sender=self)
|
||||||
await self._dispatch_message(mount_event)
|
await self._dispatch_message(mount_event)
|
||||||
|
|
||||||
|
Reactive.initialize_object(self)
|
||||||
self.title = self._title
|
self.title = self._title
|
||||||
self.stylesheet.update(self)
|
self.stylesheet.update(self)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ class MessagePump(metaclass=MessagePumpMeta):
|
|||||||
|
|
||||||
def _start_messages(self) -> None:
|
def _start_messages(self) -> None:
|
||||||
"""Start messages task."""
|
"""Start messages task."""
|
||||||
|
Reactive.initialize_object(self)
|
||||||
self._task = asyncio.create_task(self._process_messages())
|
self._task = asyncio.create_task(self._process_messages())
|
||||||
|
|
||||||
async def _process_messages(self) -> None:
|
async def _process_messages(self) -> None:
|
||||||
@@ -303,7 +304,6 @@ class MessagePump(metaclass=MessagePumpMeta):
|
|||||||
"""Process messages until the queue is closed."""
|
"""Process messages until the queue is closed."""
|
||||||
_rich_traceback_guard = True
|
_rich_traceback_guard = True
|
||||||
|
|
||||||
await Reactive.initialize_object(self)
|
|
||||||
while not self._closed:
|
while not self._closed:
|
||||||
try:
|
try:
|
||||||
message = await self._get_message()
|
message = await self._get_message()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Reactive(Generic[ReactiveType]):
|
|||||||
return cls(default, layout=False, repaint=False, init=True)
|
return cls(default, layout=False, repaint=False, init=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def initialize_object(cls, obj: object) -> None:
|
def initialize_object(cls, obj: object) -> None:
|
||||||
"""Call any watchers / computes for the first time.
|
"""Call any watchers / computes for the first time.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
Reference in New Issue
Block a user