Pass a handle to the current view model when spawning

Most of the time, we'll want a way to get a reference back to the current view or model, so this facilitates that common case.
This commit is contained in:
Nathan Sobo
2021-05-12 15:28:59 -06:00
parent fa6bd1f926
commit a3be5595dd
6 changed files with 41 additions and 44 deletions
+1 -2
View File
@@ -477,9 +477,8 @@ impl Buffer {
let snapshot = self.snapshot();
let version = self.version.clone();
let file = self.file.clone();
let handle = ctx.handle();
ctx.spawn(|mut ctx| async move {
ctx.spawn(|handle, mut ctx| async move {
if let Some(file) = new_file.as_ref().or(file.as_ref()) {
let result = ctx.read(|ctx| file.save(snapshot, ctx.as_ref())).await;
if result.is_ok() {