@@ -63,6 +63,7 @@ export const getSyncEntities = async <S extends Schema>(
63
63
* @param entityKeyClause - An array of entity key clauses to synchronize.
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
+ * @param historical - Whether to fetch and subscribe to historical events (default: true).
66
67
* @returns A promise that resolves to a subscription for event updates.
67
68
*
68
69
* @example
@@ -89,11 +90,18 @@ export const getSyncEvents = async <S extends Schema>(
89
90
clause : Clause | undefined ,
90
91
entityKeyClause : EntityKeysClause [ ] ,
91
92
limit : number = 100 ,
92
- logging : boolean = false
93
+ logging : boolean = false ,
94
+ historical : boolean = true
93
95
) => {
94
96
if ( logging ) console . log ( "Starting getSyncEvents" ) ;
95
- await getEvents ( client , components , limit , clause , logging ) ;
96
- return await syncEvents ( client , components , entityKeyClause , logging ) ;
97
+ await getEvents ( client , components , limit , clause , logging , historical ) ;
98
+ return await syncEvents (
99
+ client ,
100
+ components ,
101
+ entityKeyClause ,
102
+ logging ,
103
+ historical
104
+ ) ;
97
105
} ;
98
106
99
107
/**
@@ -150,13 +158,15 @@ export const getEntities = async <S extends Schema>(
150
158
* @param limit - The maximum number of event messages to fetch per request (default: 100).
151
159
* @param clause - An optional clause to filter event messages.
152
160
* @param logging - Whether to log debug information (default: false).
161
+ * @param historical - Whether to fetch historical events (default: true).
153
162
*/
154
163
export const getEvents = async < S extends Schema > (
155
164
client : ToriiClient ,
156
165
components : Component < S , Metadata , undefined > [ ] ,
157
166
limit : number = 100 ,
158
167
clause : Clause | undefined ,
159
- logging : boolean = false
168
+ logging : boolean = false ,
169
+ historical : boolean = true
160
170
) => {
161
171
if ( logging ) console . log ( "Starting getEvents" ) ;
162
172
let offset = 0 ;
@@ -170,7 +180,7 @@ export const getEvents = async <S extends Schema>(
170
180
clause,
171
181
dont_include_hashed_keys : false ,
172
182
} ,
173
- true
183
+ historical
174
184
) ;
175
185
176
186
if ( logging ) console . log ( "entities" , entities ) ;
@@ -291,6 +301,7 @@ export const syncEntities = async <S extends Schema>(
291
301
* @param components - An array of component definitions.
292
302
* @param entityKeyClause - An array of EntityKeysClause to filter entities.
293
303
* @param logging - Whether to log debug information (default: false).
304
+ * @param historical - Whether to sync to historical events (default: true).
294
305
* @returns A promise that resolves with the subscription handler.
295
306
* @example
296
307
* const sync = await syncEvents(client, components, entityKeyClause);
@@ -301,12 +312,13 @@ export const syncEvents = async <S extends Schema>(
301
312
client : ToriiClient ,
302
313
components : Component < S , Metadata , undefined > [ ] ,
303
314
entityKeyClause : EntityKeysClause [ ] ,
304
- logging : boolean = false
315
+ logging : boolean = false ,
316
+ historical : boolean = true
305
317
) => {
306
318
if ( logging ) console . log ( "Starting syncEvents" ) ;
307
319
return await client . onEventMessageUpdated (
308
320
entityKeyClause ,
309
- true ,
321
+ historical ,
310
322
( fetchedEntities : any , data : any ) => {
311
323
if ( logging ) console . log ( "Event message updated" , fetchedEntities ) ;
312
324
0 commit comments