Set up the core run loop
This commit is contained in:
parent
f2cca31310
commit
9b58770070
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue