Virtual DOM implemention and application definition inspired from HyperApp.
Crate that providing JSX like macro by proc_marco
and pest parser.
view! {
<button class="some-class" onclick={ |_| { Some(Action::Submit) }>
Button!
</button>
}
Squark runtime implemention for web browser with usinng stdweb.
Here is full example of counter app!
```rust
extern crate squark; extern crate squarkmacros; extern crate squarkstdweb; extern crate stdweb;
use stdweb::traits::*; use stdweb::web::document; use squark::{App, Runtime, View}; use squarkstdweb::StdwebRuntime; use squarkmacros::view;
struct State { count: isize, }
impl State { pub fn new() -> State { State { count: 0 } } }
enum Action { ChangeCount(isize), }
struct CounterApp; impl App for CounterApp { type State = State; type Action = Action;
fn reducer(mut state: State, action: Action) -> State {
match action {
Action::ChangeCount(c) => {
state.count = c;
}
};
state
}
fn view(state: State) -> View<Action> {
let count = state.count.clone();
view! {
<div>
{ count.to_string() }
<button onclick={ move |_| Some(Action::ChangeCount(count.clone() + 1)) }>
increment
</button>
<button onclick={ move |_| Some(Action::ChangeCount(count - 1)) }>
decrement
</button>
</div>
}
}
}
fn main() {
stdweb::initialize();
StdwebRuntime::
Project dir is located at examples/counter.
It is also available TodoMVC example at examples/todomvc and working on https://rail44.github.io/squark/.