Skip to content

Commit 727c87c

Browse files
committed
EventChain.create accepts arbitrary kwargs (#4609)
Pass _var_data when creating LiteralVar Partial fixes for #4608
1 parent 649171e commit 727c87c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

reflex/event.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,15 @@ def create(
437437
value: EventType,
438438
args_spec: ArgsSpec | Sequence[ArgsSpec],
439439
key: Optional[str] = None,
440+
**event_chain_kwargs,
440441
) -> Union[EventChain, Var]:
441442
"""Create an event chain from a variety of input types.
442443
443444
Args:
444445
value: The value to create the event chain from.
445446
args_spec: The args_spec of the event trigger being bound.
446447
key: The key of the event trigger being bound.
448+
**event_chain_kwargs: Additional kwargs to pass to the EventChain constructor.
447449
448450
Returns:
449451
The event chain.
@@ -462,6 +464,7 @@ def create(
462464
value=value.guess_type(),
463465
args_spec=args_spec,
464466
key=key,
467+
**event_chain_kwargs,
465468
)
466469
else:
467470
raise ValueError(
@@ -501,7 +504,9 @@ def create(
501504
result = call_event_fn(value, args_spec, key=key)
502505
if isinstance(result, Var):
503506
# Recursively call this function if the lambda returned an EventChain Var.
504-
return cls.create(value=result, args_spec=args_spec, key=key)
507+
return cls.create(
508+
value=result, args_spec=args_spec, key=key, **event_chain_kwargs
509+
)
505510
events = [*result]
506511

507512
# Otherwise, raise an error.
@@ -518,7 +523,7 @@ def create(
518523
return cls(
519524
events=events,
520525
args_spec=args_spec,
521-
event_actions={},
526+
**event_chain_kwargs,
522527
)
523528

524529

reflex/vars/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def create(
581581

582582
# Try to pull the imports and hooks from contained values.
583583
if not isinstance(value, str):
584-
return LiteralVar.create(value)
584+
return LiteralVar.create(value, _var_data=_var_data)
585585

586586
if _var_is_string is False or _var_is_local is True:
587587
return cls(

0 commit comments

Comments
 (0)