src/lib: use future rather than spawn
@@ -257,33 +257,35 @@ mod tests {
};
/*
- // @TODO fix this, it's very wrong
use futures::sync::mpsc::channel;
use futures::stream::Stream;
use enclose::*;
let (tx, rx) = channel::<Msg>(1000);
let task = rx.for_each(enclose!((tx) move |msg| {
let fx = app.update(&msg);
- for ft in fx.effects.into_iter() {
- // @TODO return a future rather than spawning
- spawn(Box::new(ft.then(enclose!((tx) move |r| {
+ let all = fx
+ .effects
+ .into_iter()
+ .map(enclose!((tx) move |ft| Box::new(ft
+ .then(enclose!((tx) move |r| {
let msg = match r {
Ok(msg) => msg,
Err(msg) => msg,
};
tx.clone().try_send(msg).expect("failed sending");
future::ok(())
- }))));
- }
- // Test code
- dbg!(&app.catalogs);
- // end test code
- future::ok(())
+ })
+ ))));
+
+ futures::future::join_all(all)
+ .map(|_| ())
}));
*/
+
// @TODO use the macro
let msg = Msg::Action(Action::Load(ActionLoad::CatalogGrouped { extra: vec![] }));
app.update(&msg);
+ dbg!(&app.catalogs);
//tx.clone().try_send(msg).expect("failed send");
//run(task);
}
