From c77712e76f3a793a4e07a09ade632a6e43f3797c Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 22 Nov 2021 16:53:50 +0800 Subject: [PATCH] feat(napi): implement with_optional_signal on AsyncTask --- crates/napi/src/bindgen_runtime/js_values/task.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/napi/src/bindgen_runtime/js_values/task.rs b/crates/napi/src/bindgen_runtime/js_values/task.rs index 5c91ad4f..a98942e9 100644 --- a/crates/napi/src/bindgen_runtime/js_values/task.rs +++ b/crates/napi/src/bindgen_runtime/js_values/task.rs @@ -35,6 +35,13 @@ impl AsyncTask { abort_signal: Some(signal), } } + + pub fn with_optional_signal(task: T, signal: Option) -> Self { + Self { + inner: task, + abort_signal: signal, + } + } } /// https://developer.mozilla.org/zh-CN/docs/Web/API/AbortController