From cd39a6fdbf1ca2f464720834b6c94c41e6264e6a Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Sun, 2 Feb 2020 21:02:26 +0800 Subject: [PATCH] Fix ResizeTask drop --- src/services/resize.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/services/resize.rs b/src/services/resize.rs index fd3593795f4..bec46fa4f71 100644 --- a/src/services/resize.rs +++ b/src/services/resize.rs @@ -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); } } }