feat: abstract commander
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-12 22:24:37 +02:00
parent 64d59e069f
commit 76f1c87663
9 changed files with 244 additions and 118 deletions

View File

@@ -3,7 +3,7 @@ use itertools::Itertools;
use crate::{
commander::{self, Commander},
models::IOEvent,
models::{IOEvent, Msg},
state::SharedState,
};
@@ -32,7 +32,7 @@ impl CreateItemCommand {
super::Command::new(|dispatch| {
tokio::spawn(async move {
dispatch.send(crate::models::Msg::ItemCreated(IOEvent::Initialized));
dispatch.send(Msg::ItemCreated(IOEvent::Initialized));
match self
.commander
@@ -50,12 +50,10 @@ impl CreateItemCommand {
{
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
dispatch.send(crate::models::Msg::ItemCreated(IOEvent::Success(())));
dispatch.send(Msg::ItemCreated(IOEvent::Success(())));
}
Err(e) => {
dispatch.send(crate::models::Msg::ItemCreated(IOEvent::Failure(
e.to_string(),
)));
dispatch.send(Msg::ItemCreated(IOEvent::Failure(e.to_string())));
}
}
});