Skip to content

Commit b8cbd79

Browse files
committed
chore: output result
1 parent df847b8 commit b8cbd79

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

examples/byop/src/byop.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use promkit::{
1212
render::{Renderer, SharedRenderer},
1313
PaneFactory,
1414
},
15-
spinner, text, text_editor,
15+
spinner, text::{self, Text}, text_editor,
1616
},
1717
Prompt, Signal,
1818
};
@@ -115,13 +115,21 @@ impl BYOP {
115115
})
116116
}
117117

118-
async fn heavy_task(&self) -> anyhow::Result<()> {
118+
async fn heavy_task(&mut self) -> anyhow::Result<()> {
119119
{
120120
let mut task_state = self.task_state.0.write().await;
121121
*task_state = TaskState::Running;
122122
};
123+
123124
// NOTE: Simulating a heavy task with a sleep.
124125
tokio::time::sleep(Duration::from_secs(5)).await;
126+
127+
// Update the result state after the task is done.
128+
self.result.text = Text::from(format!(
129+
"result: {}",
130+
self.readline.texteditor.text_without_cursor()
131+
));
132+
125133
{
126134
let mut task_state = self.task_state.0.write().await;
127135
*task_state = TaskState::Idle;

0 commit comments

Comments
 (0)