File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -291,7 +291,10 @@ export function Entity<$$Schema extends DefaultSchema>(
291291 }
292292
293293 " $$flush" ( ) {
294+ const queuedEvents = [ ...this [ " $$queuedEvents" ] ] ;
294295 this [ " $$queuedEvents" ] = [ ] ;
296+
297+ return queuedEvents ;
295298 }
296299
297300 " $$createEvent" < EventName extends InferEventNameFromSchema < $$Schema > > (
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ export function createRepository<
168168 const _entity = entity as Entity < $$Schema > ;
169169
170170 // 1. copy queued events
171- const queuedEvents = [ ... _entity [ " $$queuedEvents" ] ] ;
171+ const queuedEvents = _entity [ " $$flush" ] ( ) ;
172172
173173 // 2. commit events to adapter
174174 await args . adapter . commitEvents ( {
@@ -178,10 +178,7 @@ export function createRepository<
178178 state : _entity . state ,
179179 } ) ;
180180
181- // 3. flush queued events
182- _entity [ " $$flush" ] ( ) ;
183-
184- // 4. run plugins in parallel (only if there are events)
181+ // 3. run plugins in parallel (only if there are events)
185182 if ( args . plugins && args . plugins . length > 0 && queuedEvents . length > 0 ) {
186183 const pluginResults = await Promise . allSettled (
187184 args . plugins . map ( ( plugin ) =>
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ export interface Entity<$$Schema> {
110110 ) => void ;
111111
112112 /** @internal */
113- " $$flush" : ( ) => void ;
113+ " $$flush" : ( ) => InferEventFromSchema < $$Schema > [ ] ;
114114
115115 /** @internal */
116116 " $$createEvent" : < EventName extends InferEventNameFromSchema < $$Schema > > (
You can’t perform that action at this time.
0 commit comments