feat(example): add js-hello-world example

master
Ashley Williams 7 years ago
parent 8f5bc14b8c
commit be97683fd2
  1. 13
      examples/js-hello-world/Cargo.toml
  2. 16
      examples/js-hello-world/src/lib.rs

@ -0,0 +1,13 @@
[package]
name = "js-hello-world"
description = "an example rust->wasm crate"
version = "0.1.0"
authors = ["Ashley Williams <ashley666ashley@gmail.com>"]
license = "WTFPL"
repository = "https://github.com/ashleygwilliams/wasm-pack"
[lib]
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = { git = 'https://github.com/alexcrichton/wasm-bindgen' }

@ -0,0 +1,16 @@
#![feature(proc_macro)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
#[wasm_bindgen]
#[no_mangle]
pub extern fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
Loading…
Cancel
Save