Commit 4649bf1
committed
Handle args_spec partial args for FunctionVar
When a FunctionVar is passed to an event trigger with a given args_spec,
transform it into a partial function that applies the transformed arguments
when called. This allows FunctionVar handlers to work with on_blur and
on_submit, which, by default, use the args_spec to transform the value before
passing it off to the handler.
Some escape hatches:
* The behavior for EventChainVar is unchanged, so previous code that was
explicitly casting functions to EventChain will continue to work without
modification.
* If the FunctionVar is returned through a lambda, no partial application is
applied, because that happens at the point the lambda is called, so the
return value of the lambda is responsible for mapping the arguments if
desired.
This change also allows event handler lambda functions to return a
heterogeneous mix of EventSpec/EventHandler/FunctionVar (and EventChain
returned from lambda are treated as FunctionVar, allowing arbitrary nesting).
Update FunctionVar.partial such that passing no args does NOT create a new
useless function.1 parent 6fb6480 commit 4649bf1
2 files changed
Lines changed: 20 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
| 523 | + | |
524 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
525 | 528 | | |
526 | 529 | | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
| 530 | + | |
538 | 531 | | |
539 | 532 | | |
540 | 533 | | |
| |||
1783 | 1776 | | |
1784 | 1777 | | |
1785 | 1778 | | |
1786 | | - | |
| 1779 | + | |
1787 | 1780 | | |
1788 | 1781 | | |
1789 | 1782 | | |
| |||
1816 | 1809 | | |
1817 | 1810 | | |
1818 | 1811 | | |
1819 | | - | |
1820 | | - | |
1821 | | - | |
1822 | | - | |
1823 | 1812 | | |
1824 | 1813 | | |
1825 | 1814 | | |
| |||
1831 | 1820 | | |
1832 | 1821 | | |
1833 | 1822 | | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
1834 | 1827 | | |
1835 | | - | |
1836 | | - | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
1837 | 1837 | | |
1838 | 1838 | | |
1839 | 1839 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
0 commit comments