DioxusLabs / DioxusLabs/dioxus
Registering custom events
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Specific Demand
An easy way to add events to Dioxus without the need to mess with the source code.
## Implement Suggestion
Something that would allow a usage like, for example:
```rust
register_event! {
// attribute name
onmyevent;
// setup structure
MyeventHandler;
// elements on which it can be set
div
p
header
}
struct MyeventHandler {
...
}
impl MyeventHandler {
// Setup the event (create needed structures, hooks...)
// should be called when dioxus starts
fn new() -> Self {
...
}
// Connect a callback
fn connect(element, callback) -> Result<...> {
...
}
// Disconnect a callback
fn disconnect(element) -> Result<...> {
...
}
}
fn App(cx: Scope) -> Element {
render! {
div {
onmyevent: |event| {
...
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.