Skip to content
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

amendment of todomvc example #1409

Merged
merged 4 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/todomvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ strum = "0.18"
strum_macros = "0.18"
serde = "1"
serde_derive = "1"
wasm-bindgen = "0.2.60"
yew = { path = "../../yew" }

[lib]
crate-type = ["cdylib", "rlib"]
10 changes: 10 additions & 0 deletions examples/todomvc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ This is an implementation of [TodoMVC](http://todomvc.com/) app.

Unlike other implementations, this stores the full state of the model,
including: all entries, entered text and chosen filter.

### How to run:
This example requires rustc v1.39.0 or above to compile due to its use of the `async`/`await` syntax.

```sh
wasm-pack build --target web --out-name wasm --out-dir ./static && miniserve ./static --index index.html
```
This will compile the project, bundle the compiler output and static assets together, and start a HTTP server running locally on port 8080 (to access the example you can use your browser to navigate to [localhost:8080](http://127.0.0.1:8080)).

To run this example you'll need to have [wasm-pack](https://github.com/rustwasm/wasm-pack) and [miniserve](https://github.com/svenstaro/miniserve) installed.
6 changes: 6 additions & 0 deletions examples/todomvc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use serde_derive::{Deserialize, Serialize};
use strum::IntoEnumIterator;
use strum_macros::{EnumIter, ToString};
use wasm_bindgen::prelude::*;
use yew::events::KeyboardEvent;
use yew::format::Json;
use yew::services::storage::{Area, StorageService};
Expand Down Expand Up @@ -360,3 +361,8 @@ impl State {
self.entries.remove(idx);
}
}

#[wasm_bindgen(start)]
pub fn run_app() {
yew::start_app::<Model>();
}
3 changes: 0 additions & 3 deletions examples/todomvc/src/main.rs

This file was deleted.

5 changes: 4 additions & 1 deletion examples/todomvc/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/index.css" />
</head>
<body>
<script src="/todomvc.js"></script>
<script type="module">
import init from "./wasm.js"
init()
</script>
</body>
</html>