Simplify and clarify 'on_action'
FabienLelaquais opened this issue · 0 comments
Description
As of now, the generic 'on_action' callback is documented (in the Gui
class) as expecting three parameters: the state, the invoking element identifier, and a payload dictionary providing more context for the callback.
This to me, looks fine.
The actual implementation is different, though: an additional parameter 'action' is inserted before the payload
parameter, storing the callback name.
This seems to have been introduced when implementing Gui.__get_on_cancel_block_ui()
where instead of using the payload's 'action' property to store the callback name, is was passed directly, then a hack in Gui.__on_action()
would retrieve it.
I think this is wrong:
- the user rarely would be interested in the callback name value: he already knows where the code is implemented.
- the current implementation is wrong with respect to the documentation
I suggest we should change the code to reflect what the doc says: the action name would be a property of the payload so it can be retrieved if really needed (I don't see a realistic use case at this point). If the callback is a lambda function, the 'action' key of the payload should not be set.
Acceptance Criteria
- Ensure new code is unit tested, and check code coverage is at least 90%
- Propagate any change on the demos and run all of them to ensure there is no breaking change
- Ensure any change is well documented