Closed pjeanjean closed 3 years ago
This PR provides an alternative syntax to define event handlers, using function decorators.
The syntax without this PR looks like this:
sway = await Connection().connect() async def on_window_focus(sway, e): pass sway.on(Event.WINDOW_FOCUS, on_window_focus)
This is still supported with the changes introduced in this PR.
The only difference is that this new syntax is now also available:
sway = await Connection().connect() @sway.on(Event.WINDOW_FOCUS) async def on_window_focus(sway, e): pass
It is also possible to stack multiple decorators on the same event handler:
sway = await Connection().connect() @sway.on(Event.WINDOW_FOCUS) @sway.on(Event.WINDOW_CLOSE) @sway.on(Event.WINDOW_TITLE) async def on_window_event(sway, e): pass
Great, would you please add a test for this?
Are these enough?
:+1:
This PR provides an alternative syntax to define event handlers, using function decorators.
The syntax without this PR looks like this:
This is still supported with the changes introduced in this PR.
The only difference is that this new syntax is now also available:
It is also possible to stack multiple decorators on the same event handler: