File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
crates/bitwarden-threading/src Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,24 @@ pub mod wasm {
40
40
}
41
41
42
42
impl AbortControllerExt for AbortController {
43
+ fn to_cancellation_token ( & self ) -> CancellationToken {
44
+ self . signal ( ) . to_cancellation_token ( )
45
+ }
46
+ }
47
+
48
+ pub trait AbortSignalExt {
49
+ fn to_cancellation_token ( & self ) -> CancellationToken ;
50
+ }
51
+
52
+ impl AbortSignalExt for AbortSignal {
43
53
fn to_cancellation_token ( & self ) -> CancellationToken {
44
54
let token = CancellationToken :: new ( ) ;
45
55
46
56
let token_clone = token. clone ( ) ;
47
57
let closure = Closure :: new ( move || {
48
58
token_clone. cancel ( ) ;
49
59
} ) ;
50
- self . signal ( ) . add_event_listener ( "abort" , & closure) ;
60
+ self . add_event_listener ( "abort" , & closure) ;
51
61
closure. forget ( ) ; // Transfer ownership to the JS runtime
52
62
53
63
token
You can’t perform that action at this time.
0 commit comments