mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 06:05:24 +00:00
Implement LiveSession::restart_with_new_project as foundation for reloading
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
mem,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,8 +64,8 @@ impl LiveSession {
|
|||||||
let session_id = SessionId::new();
|
let session_id = SessionId::new();
|
||||||
|
|
||||||
Ok(LiveSession {
|
Ok(LiveSession {
|
||||||
project,
|
|
||||||
session_id,
|
session_id,
|
||||||
|
project,
|
||||||
message_queue,
|
message_queue,
|
||||||
rbx_session,
|
rbx_session,
|
||||||
imfs,
|
imfs,
|
||||||
@@ -72,7 +73,14 @@ impl LiveSession {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_project(&self) -> &Project {
|
/// Restarts the live session using the given project while preserving the
|
||||||
&self.project
|
/// internal session ID.
|
||||||
|
pub fn restart_with_new_project(&mut self, project: Arc<Project>) -> Result<(), LiveSessionError> {
|
||||||
|
let mut new_session = LiveSession::new(project)?;
|
||||||
|
new_session.session_id = self.session_id;
|
||||||
|
|
||||||
|
mem::replace(self, new_session);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user