TexteaInc / funix

Building web apps without manually creating widgets
http://funix.io
MIT License
99 stars 11 forks source link

Multiple returns in the normal way #55

Closed forrestbao closed 1 year ago

forrestbao commented 1 year ago

When a function has multiple returns, the normal way is to return them as tuples, implicitly or explicitly. For example,

def hello_world(your_name: str) -> (str, int):
    return f"Welcome to Funix, {your_name}.", len(your_name) 

Previously, Funix requires the multiple returns to be packed into a typedDict. This is very inconvenient as Funix users will have to define the typedDict first, increasing the amount of code to write. This is against the philosophy of Funix which is to reduce the amount of manual work.

Hence, please automatically handle multiple returns as tuples. Find the proper widgets based on their types.

Yazawazi commented 1 year ago

Done in https://github.com/TexteaInc/funix/commit/f4832960d63a0a8c79b7ec2b9d7f67217c0d144e

I have used type hint for additional type extensions and now support more in the return type:

Python base types and Figure are also included.

In the future: