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