File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -159,13 +159,24 @@ class PostmanSandboxFleet {
159159 /**
160160 * Dispose off all initialized sandbox instances from the fleet
161161 *
162+ * @param {Function } [callback] -
162163 * @returns {void }
163164 */
164- disposeAll ( ) {
165+ disposeAll ( callback ) {
166+ let disposedCount = 0 ;
167+
168+ if ( typeof callback !== 'function' ) {
169+ callback = _ . noop ;
170+ }
171+
165172 this . fleet . forEach ( ( context , templateName ) => {
166- context . dispose ( ) ;
173+ context . dispose ( ( ) => {
174+ this . fleet . delete ( templateName ) ;
167175
168- this . fleet . delete ( templateName ) ;
176+ if ( ++ disposedCount === this . fleet . size ) {
177+ return callback ( ) ;
178+ }
179+ } ) ;
169180 } ) ;
170181 }
171182}
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ class PostmanSandbox extends UniversalVM {
132132 } ) ;
133133 }
134134
135- dispose ( ) {
135+ dispose ( callback ) {
136136 this . once ( 'dispose' , ( ) => {
137137 _ . forEach ( this . _executing , ( irq , id ) => {
138138 irq && clearTimeout ( irq ) ;
@@ -149,6 +149,8 @@ class PostmanSandbox extends UniversalVM {
149149 this . removeAllListeners ( ASSERTION_EVENT_NAME ) ;
150150 this . removeAllListeners ( ERROR_EVENT_NAME ) ;
151151 this . disconnect ( ) ;
152+
153+ typeof callback === 'function' && callback ( ) ;
152154 } ) ;
153155
154156 this . dispatch ( 'dispose' ) ;
You can’t perform that action at this time.
0 commit comments