Use try_global()
This commit is contained in:
parent
933fb87013
commit
b807e6fe80
10 changed files with 52 additions and 70 deletions
|
@ -308,11 +308,7 @@ impl EventEmitter<Event> for Copilot {}
|
|||
|
||||
impl Copilot {
|
||||
pub fn global(cx: &AppContext) -> Option<Model<Self>> {
|
||||
if cx.has_global::<Model<Self>>() {
|
||||
Some(cx.global::<Model<Self>>().clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
cx.try_global::<Model<Self>>().map(|model| model.clone())
|
||||
}
|
||||
|
||||
fn start(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue