mirror of
https://github.com/samuelcolvin/FastUI.git
synced 2023-12-01 22:22:11 +03:00
22 lines
422 B
Python
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')]
|