Readme
README.md
# Callback Macro
This is a tag for annotating Rust functions that should be used as callbacks in
JavaScript using the kaja-web framework.
Example usage:
```rust
use kaja_html_macro;
use kaja_web::prelude::*;
#[derive(serde::Deserialize)]
struct SomeClickEvent {
index: usize,
}
#[callback("someClickCallback")]
fn some_on_click_function(event: SomeClickEvent) {
log!("event.index: {:?}", event.index);
}
pub fn example() -> String {
// This example allows you to call the Rust function from JavaScript like this:
let html = html! {{
<button onclick="someClickCallback({
index: 1
})">Run WASM Callback</button>
}};
html
}
#[wasm_bindgen(start)]
pub fn init() {
// make the callbacks available to JavaScript
init_callbacks();
}
```
## Home Page
https://kajacode.com/kajaweb.html
## Author and Contact
- Written by Johan Mattsson
- johan.mattsson.m@gmail.com
- https://kajacode.com
File history (6 commits)
Update readme
Update README.md
Pass HTML element to callback
Update README.md
Readme