-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API ergonomics #133
Comments
Yep. The ergonomics of That said, I would very much welcome something higher level (and more ergonomic) as a companion crate based on |
Makes perfect sense. I'll go ahead and close this. You mention "maybe even have it live in the same repository to ensure compatibility". How often is stdweb changing these days? Sounds like you think it'll be too difficult to track changes. |
We had quiet a few breaking changes lately (see the changelog in the README for what's going to break in I actually don't think it would be too difficult to track any future breaking changes; every breaking change is going to be documented in our changelog anyway. It would just be somewhat easier to have it in the same repository, and would ensure that the |
Sounds good. Thanks, @koute |
@jonathandturner That's not a fair comparison, since your "JavaScript" example is using jQuery, which is a quite large (and slow) dependency. This would be the fair comparison: let filter_anchors = document().query_selector_all(".filters a").unwrap();
for anchor in &filter_anchors {
let anchor: Element = anchor.try_into().unwrap();
anchor.class_list().remove("selected").unwrap();
} var filterAnchors = document.querySelectorAll(".filters a");
for (let anchor of filterAnchors) {
anchor.classList.remove("selected");
} The primary differences between them is that Rust has more verbose (but more correct) error-handling (e.g. Having said that, you are completely right that the current APIs are complex (mostly because the equivalent DOM APIs are complex). I am currently working on a Virtual DOM implementation on top of stdweb which should help out a lot with that. |
Earlier I had mentioned creating a virtual DOM library for stdweb, and I have finally published it to crates.io. You can use it like this: html!("div", {
event(|e: ClickEvent| {
...
});
children(&mut [
html!("div", {
style("width", "50px");
style("height", "50px");
style("background-color", "green");
}),
]);
}) It has a ton of other useful stuff as well. You can read more about it here. |
Great work! Definitely very cool.
Looking through the TodoMVC example, there are some places that could use a bit of tightening to give them the same "lightness" of the equivalent JS.
Here's one:
And the equivalent JS:
While the Rust might not get quite that small, a bit of API "golf" I think could help it feel as easy to use as jQuery or equivalent libraries.
Alternatively, maybe we need a jQuery-like library that sits on top of stdweb?
The text was updated successfully, but these errors were encountered: