Set up the core run loop

This commit is contained in:
Savanni D'Gerinel 2023-03-20 09:43:48 -04:00
parent f2cca31310
commit 9b58770070
1 changed files with 8 additions and 4 deletions

View File

@ -11,11 +11,12 @@ pub enum Request {
PlayingField,
}
#[derive(Debug)]
pub enum Response {
PlayingFieldView(PlayingFieldView),
}
fn disptach(state: Arc<RwLock<AppState>>, request: Request) -> Response {
fn dispatch(state: Arc<RwLock<AppState>>, request: Request) -> Response {
match request {
Request::PlayingField => Response::PlayingFieldView(playing_field()),
}
@ -45,8 +46,11 @@ impl CoreApp {
)
}
pub async fn run(&self) {
thread::sleep(Duration::from_secs(5));
unimplemented!()
pub async fn run(&mut self) {
loop {
let msg = self.request_rx.recv().await.unwrap();
let resp = dispatch(self.state.clone(), msg);
self.response_tx.send(resp).await.unwrap();
}
}
}