Skip to content
Discussion options

You must be logged in to vote

No, I would not explicitly construct AwaitComplete in the handler. In the version I sketched, set_items is an async helper, so the call site should just be an async handler and await self.set_items(...):

async def on_key(self, event: events.Key) -> None:
    if event.key == "backspace":
        await self.set_items(menu_data, path)

async def on_list_view_selected(self, event: ListView.Selected) -> None:
    await self.set_items(next_menu_data, next_path)

AwaitComplete is mainly for APIs that return an optionally-awaitable object; Textual's docs say you are unlikely to need to create it yourself. Textual also awaits async message handlers. Docs: https://textual.textualize.io/api/await_com…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@derVedro
Comment options

@cookesan
Comment options

Answer selected by derVedro
@derVedro
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants