feat(napi): implement with_optional_signal on AsyncTask

This commit is contained in:
LongYinan 2021-11-22 16:53:50 +08:00
parent 43c1aff738
commit c77712e76f
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7

View file

@ -35,6 +35,13 @@ impl<T: Task> AsyncTask<T> {
abort_signal: Some(signal),
}
}
pub fn with_optional_signal(task: T, signal: Option<AbortSignal>) -> Self {
Self {
inner: task,
abort_signal: signal,
}
}
}
/// https://developer.mozilla.org/zh-CN/docs/Web/API/AbortController