logic.rs
1.07 KB
use mogwai::prelude::*;
use crate::api::image::{Image, images};
use super::{PatchSender, view::image_preview_view};
pub(super) async fn image_preview_logic() {
}
pub(super) async fn selector_logic( mut rx_dom :broadcast::Receiver<Dom>
, tx_previews :PatchSender) {
let mut previews :ListPatchModel<Image> = ListPatchModel::new();
mogwai::spawn(previews.stream().for_each(move |patch| {
let patch :ListPatch<ViewBuilder<Dom>> = patch.map(|i| {
let view = image_preview_view(
String::from(format!( "/api/v0/images/{}?size=thumbnail"
, i.json.id )));
let logic = image_preview_logic();
Component::from(view).with_logic(logic).into()
});
let tx_previews = tx_previews.clone();
async move {
tx_previews.send(patch).await.unwrap();
}
}));
if let Some(_) = rx_dom.next().await {
for image in images().await.unwrap().into_iter() {
previews.list_patch_push(image);
}
}
}