Files
FastUI/python/fastui/events.py
Samuel Colvin e06fddf29e Bootstrap (#5)
2023-11-24 10:28:20 +00:00

22 lines
422 B
Python

from typing import Annotated, Literal
from pydantic import BaseModel, Field
class PageEvent(BaseModel):
name: str
type: Literal['page'] = 'page'
class GoToEvent(BaseModel):
# can be a path or a full URL
url: str
type: Literal['go-to'] = 'go-to'
class BackEvent(BaseModel):
type: Literal['back'] = 'back'
AnyEvent = Annotated[PageEvent | GoToEvent | BackEvent, Field(discriminator='type')]