File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -74,19 +74,21 @@ export class SmtpClient {
74
74
return this . #currentlySending
75
75
}
76
76
77
- #idleCB = new Set < ( ) => void > ( )
78
-
79
- get waitIdle ( ) {
80
- if ( ! this . isSending ) return Promise . resolve ( )
81
-
82
- return new Promise < void > ( ( res ) => { this . #idleCB. add ( res ) } )
77
+ get idle ( ) {
78
+ return this . #idlePromise
83
79
}
84
80
81
+ #idlePromise = Promise . resolve ( )
82
+ #idleCB = ( ) => { }
83
+
85
84
#currentlySending = false ;
86
85
#sending: ( ( ) => void ) [ ] = [ ] ;
87
86
88
87
#cueSending( ) {
89
88
if ( ! this . #currentlySending) {
89
+ this . #idlePromise = new Promise ( ( res ) => {
90
+ this . #idleCB = res
91
+ } )
90
92
this . #currentlySending = true ;
91
93
return ;
92
94
}
@@ -102,7 +104,7 @@ export class SmtpClient {
102
104
#queNextSending( ) {
103
105
if ( this . #sending. length === 0 ) {
104
106
this . #currentlySending = false ;
105
- this . #idleCB. forEach ( cb => cb ( ) )
107
+ this . #idleCB( )
106
108
return ;
107
109
}
108
110
You can’t perform that action at this time.
0 commit comments