@@ -64,6 +64,7 @@ export const getSyncEntities = async <S extends Schema>(
64
64
* @param limit - The maximum number of events to fetch per request (default: 100).
65
65
* @param logging - Whether to log debug information (default: false).
66
66
* @param historical - Whether to fetch and subscribe to historical events (default: false).
67
+ * @param callback - An optional callback function to be called after fetching events.
67
68
* @returns A promise that resolves to a subscription for event updates.
68
69
*
69
70
* @example
@@ -91,17 +92,20 @@ export const getSyncEvents = async <S extends Schema>(
91
92
entityKeyClause : EntityKeysClause [ ] ,
92
93
limit : number = 100 ,
93
94
logging : boolean = false ,
94
- historical : boolean = true
95
+ historical : boolean = true ,
96
+ callback ?: ( ) => void
95
97
) => {
96
98
if ( logging ) console . log ( "Starting getSyncEvents" ) ;
97
- await getEvents ( client , components , limit , clause , logging , historical ) ;
98
- return await syncEvents (
99
+ await getEvents (
99
100
client ,
100
101
components ,
101
- entityKeyClause ,
102
+ limit ,
103
+ clause ,
102
104
logging ,
103
- historical
105
+ historical ,
106
+ callback
104
107
) ;
108
+ return await syncEvents ( client , components , entityKeyClause , logging ) ;
105
109
} ;
106
110
107
111
/**
@@ -159,14 +163,16 @@ export const getEntities = async <S extends Schema>(
159
163
* @param clause - An optional clause to filter event messages.
160
164
* @param logging - Whether to log debug information (default: false).
161
165
* @param historical - Whether to fetch historical events (default: false).
166
+ * @param callback - An optional callback function to be called after fetching events.
162
167
*/
163
168
export const getEvents = async < S extends Schema > (
164
169
client : ToriiClient ,
165
170
components : Component < S , Metadata , undefined > [ ] ,
166
171
limit : number = 100 ,
167
172
clause : Clause | undefined ,
168
173
logging : boolean = false ,
169
- historical : boolean = false
174
+ historical : boolean = false ,
175
+ callback ?: ( ) => void
170
176
) => {
171
177
if ( logging ) console . log ( "Starting getEvents" ) ;
172
178
let offset = 0 ;
@@ -193,6 +199,8 @@ export const getEvents = async <S extends Schema>(
193
199
offset += limit ;
194
200
}
195
201
}
202
+
203
+ callback && callback ( ) ;
196
204
} ;
197
205
198
206
/**
0 commit comments