fix(napi): allow ErrorStrategy to be specified while creating TSFN

This commit is contained in:
LongYinan 2021-11-21 14:49:04 +08:00
parent d7da82e269
commit d1a5f84aa0
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
6 changed files with 30 additions and 9 deletions
crates/napi/src/js_values

View file

@ -120,15 +120,16 @@ impl JsFunction {
}
#[cfg(feature = "napi4")]
pub fn create_threadsafe_function<T, V, F>(
pub fn create_threadsafe_function<T, V, F, ES>(
&self,
max_queue_size: usize,
callback: F,
) -> Result<ThreadsafeFunction<T>>
) -> Result<ThreadsafeFunction<T, ES>>
where
T: 'static,
V: NapiRaw,
F: 'static + Send + FnMut(ThreadSafeCallContext<T>) -> Result<Vec<V>>,
ES: crate::threadsafe_function::ErrorStrategy::T,
{
ThreadsafeFunction::create(self.0.env, self.0.value, max_queue_size, callback)
}