Action¶
-
class
binp.action.
Action
[source]¶ Expose user-defined action as ‘button’ in UI
Expose async function as button to ui.
It will not be automatically journaled: it’s up to you add
@binp.journal
annotation or not.- Example
from binp import BINP from asyncio import sleep binp = BINP() @binp.action async def invoke(): ''' Do something ''' await sleep(3) # emulate some work print("done")
By default, action will be exposed with name equal to fully-qualified function name and description from doc-string (if exists).
Exposed name could by optionally defined manually.
from binp import BINP from asyncio import sleep binp = BINP() @binp.action(name='Do Something', description='Emulate some heavy work') async def invoke(): await sleep(3) print("done")
- Conflicts
Actions are indexed by name. If multiple actions defined with the same name - the latest one will be used.
-
property
actions
¶ Copy of list of defined actions prepared for serialization.
- Return type
List
[ActionInfo
]