Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanay-pingalkar/rq
A jquery inspired library for wasm made in rust
https://github.com/tanay-pingalkar/rq
rust rust-library rust-wasm wasm wasm-bindgen wasm-library
Last synced: about 2 months ago
JSON representation
A jquery inspired library for wasm made in rust
- Host: GitHub
- URL: https://github.com/tanay-pingalkar/rq
- Owner: tanay-pingalkar
- License: mit
- Created: 2021-06-15T12:18:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-16T07:23:56.000Z (over 3 years ago)
- Last Synced: 2024-10-31T22:33:07.529Z (3 months ago)
- Topics: rust, rust-library, rust-wasm, wasm, wasm-bindgen, wasm-library
- Language: Rust
- Homepage:
- Size: 38.1 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rq
A jquery inspired library for wasm made in rust## rq::I
`I` stands for id to get element.
You can use it like this
``` rust
use req;
use web_sys::console;rq::I::new("class-name")
.unwrap()
.html("manipulating dom from rust")
.on("click",Box::new(move |event| {
console::log_2(&"clicked : ".into(), &event.into())
}))
```## req::N
`N` stands for new to create new element.
``` rust
use req;
use web_sys::console;rq::N::new("p") // name of tag
.unwrap()
.html("content of tag")
.on("click",Box::new(move |event| {
console::log_2(&"event : ".into(), &event.into())
}))
.append("id")
.unwrap()
```## req::C
`C` stands for class to get elements by class name.
``` rust
use req;
use web_sys::console;rq::C::new("class-name") // name of tag
.unwrap()
.html("rq looks good")
.on("click",Box::new(move |event| {
console::log_2(&"event : ".into(), &event.into())
}))
```## html_cj
html_cj takes a closure and return the html, it is important when you have to change the html of element based on previous html
``` rust
use req;rq::N::new("button")
.unwrap()
.html("0")
.id("btn-id")
.on("click",Box::new(move |event| {
req::I::new("btn-id")
.unwrap()
.html_cj(|html| {
let html = html.parse::().unwrap() + 1;
html.to_string()
});
}))
```currently the api is small and i am still learning rust. I will add more features to it so stay tuned.