2023-03-20 12:16:20 +00:00
|
|
|
use crate::types::AppState;
|
2023-03-24 13:59:04 +00:00
|
|
|
use crate::ui::{playing_field, PlayingFieldView};
|
|
|
|
use std::sync::{Arc, RwLock};
|
2023-03-20 12:16:20 +00:00
|
|
|
|
|
|
|
pub enum Request {
|
|
|
|
PlayingField,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Response {
|
|
|
|
PlayingFieldView(PlayingFieldView),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct CoreApp {
|
|
|
|
state: Arc<RwLock<AppState>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CoreApp {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
let state = Arc::new(RwLock::new(AppState::new()));
|
|
|
|
|
|
|
|
Self { state }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn dispatch(&self, request: Request) -> Response {
|
|
|
|
match request {
|
|
|
|
Request::PlayingField => Response::PlayingFieldView(playing_field()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn run(&self) {}
|
|
|
|
}
|