From 277693443e061cd080f1f8aa2bb5c0881af3269e Mon Sep 17 00:00:00 2001 From: DavidOConnor Date: Sun, 9 Dec 2018 21:05:00 -0500 Subject: [PATCH] tweaks to readme, and added a bit more functionality to lib --- .gitignore | 4 ++ .idea/inspectionProfiles/Project_Default.xml | 40 ++++++++++++++++++++ .idea/misc.xml | 13 +++++++ .idea/modules.xml | 8 ++++ .idea/seed-quickstart.iml | 11 ++++++ .idea/vcs.xml | 6 +++ Cargo.toml | 2 +- README.md | 15 +++++++- src/lib.rs | 13 ++++--- 9 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/seed-quickstart.iml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 6c1daf5..915a6c8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,9 @@ **/*.rs.bk Cargo.lock +# Pycharm +*.iws +workspace.xml + **/pkg/* **/.wasm \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..d80a413 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,40 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..76d16a3 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..857fb90 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/seed-quickstart.iml b/.idea/seed-quickstart.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/.idea/seed-quickstart.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 8682a8c..08ed3e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] [dependencies] seed = "^0.1.0" -wasm-bindgen = "^0.2.28" +wasm-bindgen = "^0.2.29" web-sys = "^0.3.6" # For serialization, eg sending requests to a server. Otherwise, not required. diff --git a/README.md b/README.md index 1ace3c0..d250704 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,17 @@ To get started with, clone this repo, and make the following changes: crate's name - Make the same replacement in either `build.sh`, or `build.ps1`, depending on your -operating system (`.sh` for Linux, `.ps` for Windows). You may delete the other one \ No newline at end of file +operating system (`.sh` for Linux, `.ps` for Windows). You may delete the other one. + + +- If you don't have Rust installed, nightly set up, and wasm-bindgen, [Download it](https://www.rust-lang.org/en-US/), and run the following commands: + +`rustup update` + +`rustup default nightly` + +`rustup target add wasm32-unknown-unknown --toolchain nightly` + +`cargo +nightly install wasm-bindgen-cli` + + - Run `build.sh` or `build.ps1`, then open `index.html` in a web browser. \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index b920ef6..2d56a86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,20 +29,21 @@ enum Msg { fn update(msg: &Msg, model: &Model) -> Model { match msg { - Msg::Increment => { - Model {val: model.val + 1} - }, + Msg::Increment => Model {val: model.val + 1} } } // View -fn main_comp(model: &Model) -> El { - div![ "Hello, World" ] +fn view(model: &Model) -> El { + button![ + vec![simple_ev("click", Msg::Increment)], + format!("Hello, World × {}", model.val) + ] } #[wasm_bindgen] pub fn render() { - seed::vdom::run(Model::default(), update, main_comp, "main"); + seed::run(Model::default(), update, view, "main"); } \ No newline at end of file