Skip to content

Commit

Permalink
chore: log when cancelling a task
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Nov 7, 2023
1 parent be3e4a4 commit a131394
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/app/state/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ impl<T> Datum<T> {
// Cancel existing fetcher if any.
signal.with_mut(move |x| {
if let Some(abort_handle) = x.task.take() {
tracing::warn!(
"🍒 Cancelling previous refresh task for {}",
std::any::type_name::<T>()
);
abort_handle.abort();
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/app/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ impl AppState {
// Build `state.flake` signal when `state.flake_url` changes or the
// RefreshFlake action is triggered
{
let refresh_flake = |(flake_url, idx): (Option<FlakeUrl>, Option<usize>)| async move {
let refresh_flake = |(flake_url, last_event_idx): (Option<FlakeUrl>, Option<usize>)| async move {
if let Some(flake_url) = flake_url {
tracing::info!("Updating flake [{}] {:?} ...", flake_url, idx);
tracing::info!("Updating flake [{}] {:?} ...", flake_url, last_event_idx);
Datum::refresh_with(self.flake, async move {
Flake::from_nix(&nix_rs::command::NixCmd::default(), flake_url.clone())
.await
Expand Down Expand Up @@ -147,8 +147,8 @@ impl AppState {
let get_nix_info_action =
Action::signal_for(cx, self.action, |act| act == Action::GetNixInfo);
let idx = *get_nix_info_action.read();
use_future(cx, (&idx,), |(idx,)| async move {
tracing::info!("Updating nix info [{:?}] ...", idx);
use_future(cx, (&idx,), |(last_event_idx,)| async move {
tracing::info!("Updating nix info [{:?}] ...", last_event_idx);
Datum::refresh_with(self.nix_info, async {
NixInfo::from_nix(&nix_rs::command::NixCmd::default())
.await
Expand Down

0 comments on commit a131394

Please sign in to comment.