Explorar o código

allow preventing page updates by returning result of callable handler

Falko Schindler %!s(int64=3) %!d(string=hai) anos
pai
achega
b9f569564a
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      nicegui/events.py

+ 5 - 2
nicegui/events.py

@@ -201,13 +201,16 @@ def handle_event(handler: Optional[Union[Callable, Awaitable]], arguments: Event
         if handler is None:
             return
         no_arguments = not signature(handler).parameters
-        call = handler() if no_arguments else handler(arguments)
+        result = handler() if no_arguments else handler(arguments)
         if asyncio.iscoroutinefunction(handler):
             async def async_handler():
                 try:
-                    await call
+                    await result
                 except Exception:
                     traceback.print_exc()
             asyncio.get_event_loop().create_task(async_handler())
+            return False
+        else:
+            return result
     except Exception:
         traceback.print_exc()