Update when.md (#1554)

* Update when.md: include info on importing when to get access

---------

Co-authored-by: Jeff Glass <glass.jeffrey@gmail.com>
This commit is contained in:
Neon22
2023-06-22 10:56:47 +12:00
committed by GitHub
parent 7765a629c7
commit 9a70943a36

View File

@@ -6,6 +6,9 @@ The `@when` decorator attaches the decorated function or Callable as an event ha
If the decorated function takes a single (non-self) argument, it will be passed the [Event object](https://developer.mozilla.org/en-US/docs/Web/API/Event) corresponding to the triggered event. If the function takes no (non-self) argument, it will be called with no arguments. If the decorated function takes a single (non-self) argument, it will be passed the [Event object](https://developer.mozilla.org/en-US/docs/Web/API/Event) corresponding to the triggered event. If the function takes no (non-self) argument, it will be called with no arguments.
You will need to import `when` to get access to this feature:
`from pyscript import when`
## Parameters ## Parameters
`event_type` - A string representing the event type to match against. This can be any of the [https://developer.mozilla.org/en-US/docs/Web/Events#event_listing](https://developer.mozilla.org/en-US/docs/Web/Events) that HTML elements may emit, as appropriate to their element type. `event_type` - A string representing the event type to match against. This can be any of the [https://developer.mozilla.org/en-US/docs/Web/Events#event_listing](https://developer.mozilla.org/en-US/docs/Web/Events) that HTML elements may emit, as appropriate to their element type.