Use Closure::once instead of Closure::wrap

This commit is contained in:
Edward Shen 2021-10-31 12:43:44 -07:00
parent 1d4d37b6ea
commit f748fbf265
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -257,18 +257,16 @@ fn on_success(event: &Event, decrypted: &DecryptedData, expires: &str) {
) )
.unwrap(); .unwrap();
put_action.set_onsuccess(Some( put_action.set_onsuccess(Some(
Closure::wrap(Box::new(|| { Closure::once(Box::new(|| {
log!("success"); log!("success");
load_from_db(); load_from_db();
}) as Box<dyn Fn()>) }))
.into_js_value() .into_js_value()
.unchecked_ref(), .unchecked_ref(),
)); ));
put_action.set_onerror(Some( put_action.set_onerror(Some(
Closure::wrap(Box::new(|e| { Closure::once(Box::new(|e: Event| log!(e)))
log!(e); .into_js_value()
}) as Box<dyn Fn(Event)>) .unchecked_ref(),
.into_js_value()
.unchecked_ref(),
)); ));
} }