File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,17 @@ type ShellEvent = {
17
17
args : string [ ] ;
18
18
} ;
19
19
20
-
21
-
22
20
const createId = ( ) => Math . floor ( Math . random ( ) * 9999 ) + 1 ;
23
21
24
22
const useShell = ( ) => {
23
+ const on = ( name : string , listener : ( arg : any ) => void ) => {
24
+ events . on ( name , listener ) ;
25
+ } ;
26
+
27
+ const off = ( name : string , listener : ( arg : any ) => void ) => {
28
+ events . off ( name , listener ) ;
29
+ } ;
30
+
25
31
const send = ( method : string , ...args : ( string | number ) [ ] ) => {
26
32
try {
27
33
transport ?. send ( JSON . stringify ( {
@@ -31,19 +37,11 @@ const useShell = () => {
31
37
method : 'onEvent' ,
32
38
args : [ method , ...args ] ,
33
39
} ) ) ;
34
- } catch ( e ) {
40
+ } catch ( e ) {
35
41
console . error ( 'Shell' , 'Failed to send event' , e ) ;
36
42
}
37
43
} ;
38
44
39
- const on = ( name : string , listener : ( arg : any ) => void ) => {
40
- events . on ( name , listener ) ;
41
- } ;
42
-
43
- const off = ( name : string , listener : ( arg : any ) => void ) => {
44
- events . off ( name , listener ) ;
45
- } ;
46
-
47
45
useEffect ( ( ) => {
48
46
if ( ! transport ) return ;
49
47
You can’t perform that action at this time.
0 commit comments