Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More PageEvent Triggers #104

Closed
shroominic opened this issue Dec 17, 2023 · 2 comments
Closed

More PageEvent Triggers #104

shroominic opened this issue Dec 17, 2023 · 2 comments

Comments

@shroominic
Copy link

I think we need more ways to trigger PageEvents like

  • OnPageLoad
  • OnFormSubmit
  • FromJSScript?
@samuelcolvin
Copy link
Member

on page load should be covered by the FireEvent component:

class FireEvent(_p.BaseModel, extra='forbid'):
event: events.AnyEvent
message: _t.Union[str, None] = None # defaults to blank
type: _t.Literal['FireEvent'] = 'FireEvent'

on form submit was done in #93:

submit_trigger: _t.Union[events.PageEvent, None] = pydantic.Field(default=None, serialization_alias='submitTrigger')

from JS should be pretty easy since page events are just CustomEvents called on the document itself:

document.dispatchEvent(new CustomEvent(pageEventType(event), { detail }))

I guess we could export a wrapper for this?

@shroominic
Copy link
Author

Uhh nice thanks! Was searching in the .venv/lib but its not yet released so I will pull from git and try to implement streaming responses to fastui-chat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants