Fix ResizeTask drop (#915)

This commit is contained in:
Justin Starry 2020-02-03 09:52:28 +08:00 committed by GitHub
parent 3dca0c7758
commit ee4792c7f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,11 +54,9 @@ impl ResizeService {
callback.emit(dimensions); callback.emit(dimensions);
}; };
let handle = js! { let handle = js! {
var callback = @{callback}; var handle = @{callback};
var action = function() { window.addEventListener("resize", handle);
callback(); return handle;
};
return window.addEventListener("resize", action);
}; };
ResizeTask(Some(handle)) ResizeTask(Some(handle))
} }
@ -70,7 +68,7 @@ impl Drop for ResizeTask {
js! { js! {
@(no_return) @(no_return)
var handle = @{handle}; var handle = @{handle};
handle.callback.drop(); window.removeEventListener("resize", handle);
} }
} }
} }