Skip to content

Commit 8bd10b5

Browse files
committed
just store the html/vnode
1 parent baeb5cb commit 8bd10b5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/wasm/main.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![cfg(feature = "wasm")]
22
use yew::prelude::*;
3+
use yew::virtual_dom::VNode;
34

45
use cega::wasm::image::*;
56
use cega::wasm::{FileInput, FileUpload};
@@ -9,7 +10,7 @@ pub enum Msg {
910
}
1011

1112
pub struct App {
12-
files: Vec<FileUpload>,
13+
images: Vec<VNode>,
1314
}
1415

1516
impl Component for App {
@@ -18,14 +19,14 @@ impl Component for App {
1819

1920
fn create(_ctx: &Context<Self>) -> Self {
2021
Self {
21-
files: Vec::default(),
22+
images: Vec::default(),
2223
}
2324
}
2425

2526
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
2627
match msg {
2728
Msg::Loaded(file) => {
28-
self.files.push(file);
29+
self.images.push(html! { <ImageComponent file={file} /> });
2930
}
3031
}
3132
true
@@ -37,9 +38,7 @@ impl Component for App {
3738
<h1>{ "Process your CGA/EGAs" }</h1>
3839
<FileInput accept="image/*,.bin,.cga,.ega" onload={ctx.link().callback( Msg::Loaded )}/>
3940
<div id="preview-area">
40-
{for self.files.iter().map(|f|
41-
html! { <ImageComponent file={f.clone()} /> }
42-
)}
41+
{{ self.images.clone() }}
4342
</div>
4443
</div>
4544
}

0 commit comments

Comments
 (0)