forked from brl/citadel-tools
Emit event when creating a new realm
This commit is contained in:
parent
220920cb2f
commit
160fc47494
@ -59,7 +59,7 @@ impl Inner {
|
||||
self.manager = Arc::downgrade(manager);
|
||||
}
|
||||
|
||||
pub fn add_handler<F>(&mut self, handler: F)
|
||||
fn add_handler<F>(&mut self, handler: F)
|
||||
where F: Fn(&RealmEvent),
|
||||
F: 'static + Send + Sync
|
||||
{
|
||||
@ -109,6 +109,12 @@ impl RealmEventListener {
|
||||
self.running.swap(val, Ordering::SeqCst)
|
||||
}
|
||||
|
||||
pub fn send_event(&self, event: RealmEvent) {
|
||||
if self.is_running() {
|
||||
self.inner().send_event(event);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_handler<F>(&self, handler: F)
|
||||
where F: Fn(&RealmEvent),
|
||||
F: 'static + Send + Sync
|
||||
|
@ -356,7 +356,9 @@ impl RealmManager {
|
||||
}
|
||||
|
||||
pub fn new_realm(&self, name: &str) -> Result<Realm> {
|
||||
self.inner_mut().realms.create_realm(name)
|
||||
let realm = self.inner_mut().realms.create_realm(name)?;
|
||||
self.inner().events.send_event(RealmEvent::New(realm.clone()));
|
||||
Ok(realm)
|
||||
}
|
||||
|
||||
pub fn delete_realm(&self, realm: &Realm, save_home: bool) -> Result<()> {
|
||||
|
Loading…
Reference in New Issue
Block a user