File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
libs/providers/go-feature-flag/src/lib/service Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,19 @@ export class EventPublisher {
4949 return ;
5050 }
5151 this . isRunning = true ;
52- const flushInterval = this . options . dataFlushInterval || DEFAULT_FLUSH_INTERVAL_MS ;
53- this . intervalId = setInterval ( async ( ) => {
54- await this . publishEvents ( ) ;
55- } , flushInterval ) ;
52+ this . runPublisher ( ) ;
53+ }
54+
55+ /**
56+ * Runs the publisher and sets up a periodic runner.
57+ * @returns {Promise<void> } A promise that resolves when the publisher has run.
58+ */
59+ private async runPublisher ( ) : Promise < void > {
60+ await this . publishEvents ( ) ;
61+ if ( this . isRunning ) {
62+ const flushInterval = this . options . dataFlushInterval || DEFAULT_FLUSH_INTERVAL_MS ;
63+ this . intervalId = setTimeout ( ( ) => this . runPublisher ( ) , flushInterval ) ;
64+ }
5665 }
5766
5867 /**
You can’t perform that action at this time.
0 commit comments