Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
naps62 committed Aug 1, 2020
1 parent 941a16b commit 3182a88
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions ui/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const wasmPlugin = {
outDir: path.resolve(__dirname, "./src/wasm"),
})
);
console.log(webpackConfig);
return webpackConfig;
},
},
Expand Down
12 changes: 4 additions & 8 deletions ui/src/components/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React, { useState, useEffect } from "react";
import { useWasm, useTakeEffect } from "../../utils/wasm";
import * as Wasm from "../../wasm";
import "./style.css";

const Settings: React.FC = () => {
const wasm = useWasm();
const wasm = Wasm.use();
const [settings, setSettings] = useState("");

// useTakeEffect(() => {
// wasm.set_settings("asd");
// }, [wasm]);

useTakeEffect(() => {
setSettings("{}");
Wasm.useEffect(() => {
wasm.set_settings("asd");
}, [wasm]);

const onSubmit = (e: any) => {
Expand Down
2 changes: 2 additions & 0 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "instacam-wasm"
version = "0.1.0"
authors = ["Miguel Palhas <[email protected]>"]
edition = "2018"
wasm-opt = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down Expand Up @@ -32,3 +33,4 @@ wasm-bindgen-test = "0.3.13"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

7 changes: 1 addition & 6 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ extern "C" {
}

#[wasm_bindgen]
pub fn getSettings(settings: &str) -> String {
"{}".into()
}

#[wasm_bindgen]
pub fn setSettings(settings: &str) {
pub fn set_settings(settings: &str) {
js_log(format!("Hello, instacam-ui from wasm! {}", settings).as_str());
}

0 comments on commit 3182a88

Please sign in to comment.