-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add listener skeleton for logging on the UI
- Loading branch information
Showing
4 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::ui::window::UI; | ||
use async_trait::async_trait; | ||
use std::sync::Arc; | ||
|
||
#[async_trait] | ||
pub trait Logger { | ||
async fn logger(self: Arc<Self>); | ||
} | ||
|
||
#[async_trait] | ||
impl Logger for UI { | ||
async fn logger(self: Arc<Self>) { | ||
tokio::spawn(async move { | ||
let mut receiver = self.sender.subscribe(); | ||
|
||
loop { | ||
let m = receiver.recv().await.unwrap(); | ||
print!("{m}"); | ||
}; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod window; | ||
pub mod toggle_switch; | ||
pub mod listener; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters