You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2f71cdf
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(event): accept any sequence of events where a list of them is accepted (#7402)
* feat(event): accept any sequence of events where a list of them is accepted
* fix(app): read a page's on_load and the form on_submit events as any sequence
* perf(event): check the single event kinds before the Sequence ABC in from_event_type
* fix(internal): read the forms' on_submit sequence without the new helper, so the declared reflex floor still type-checks
* fix(internal): reject a string as the forms' on_submit events instead of splitting it into characters
* fix(event): split any sequence an event lambda returns into its events
call_event_fn only split a list or tuple, so a lambda returning another
sequence such as a UserList was wrapped as one event and rejected.
* refactor(event): share one fast check for a single event or a sequence
is_non_string_sequence checks list and tuple before the Sequence ABC, and
excludes bytes as well as str. _check_valid_yield uses it instead of its own
copy of the check.
from_event_type, fix_events and call_event_fn wrap a single event through
one _event_sequence helper. EventChain.create keeps its own branches, so a
bad top-level value still reports "Invalid event chain".
The demo and intro forms drop the string guard: the type already excludes
a str, and the event chain rejects one anyway.
Tests cover a handler that returns or yields a tuple through the event
processor, and which values count as a sequence.
* build(reflex): require the reflex-base that has is_non_string_sequence
reflex/app.py imports is_non_string_sequence, which reflex-base 0.10.0 lacks.
* Revert "build(reflex): require the reflex-base that has is_non_string_sequence"
pin-exact rewrites the reflex-base requirement to == <version> at build time, so
a released reflex never installs with an older reflex-base.
* feat(event): make event_sequence public and use it in the internal forms
The demo and intro forms turn their on_submit into a list of events with
reflex_base.event.event_sequence instead of their own isinstance check.
* build(internal): require the reflex that has event_sequence
The demo and intro forms import event_sequence, which reflex 0.10.0 and older lack.
---------
Co-authored-by: Farhan <www.mfarvirus@gmail.com>
Co-authored-by: Farhan Ali Raza <62690310+FarhanAliRaza@users.noreply.github.com>
Co-authored-by: Masen Furer <m_github@0x26.net>
Event props and the events an event handler returns accept any sequence of events, e.g. a tuple or a variable typed `list[EventSpec]`, not only a list literal. The new `reflex_base.event.event_sequence` helper returns such a value as a sequence of events, wrapping a single event in a list.
0 commit comments