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);
};
let handle = js! {
var callback = @{callback};
var action = function() {
callback();
};
return window.addEventListener("resize", action);
var handle = @{callback};
window.addEventListener("resize", handle);
return handle;
};
ResizeTask(Some(handle))
}
@ -70,7 +68,7 @@ impl Drop for ResizeTask {
js! {
@(no_return)
var handle = @{handle};
handle.callback.drop();
window.removeEventListener("resize", handle);
}
}
}