Additive schedule registration for TypeScript for file-splitting#5435
Additive schedule registration for TypeScript for file-splitting#5435JasonAtClockwork wants to merge 5 commits into
Conversation
| const schedule = | ||
| scheduled && scheduleAtCol !== undefined | ||
| ? { scheduleAtCol, reducer: scheduled } | ||
| ? { reducer: scheduled as () => UntypedScheduledFunctionExport } |
There was a problem hiding this comment.
NIT: as is usually a TypeSystem code smell. Not 100% of the time, but 95% of the time there's something better we could do here.
| } | ||
| ); | ||
|
|
||
| const spacetimedbSchedules = schema({ scheduledMessages }); |
There was a problem hiding this comment.
By convention we should always call the value returned from schema: spacetimedb.
|
For context, the solution that @coolreader18 and I discussed was to allow you to specify on the reducer, the table you wanted to schedule to. The one detail is that we would need to enforce (at least for now), that at most (and perhaps exactly) one reducer was subscribed to a schedule table. The reason being is that the calling order would not be well defined, and we didn't want people to rely on whatever order we end up calling them in. So that would look like this: const scheduledMessages = table({public: true}, {
scheduledId: t.u64().primaryKey().autoInc(),
scheduledAt: t.scheduleAt(),
text: t.string(),
});
const spacetimedb = schema({ scheduledMessages });
spacetime.reducer({ on_schedule = spacetimedb.scheduledMessages });
// or something similarThe idea was that it would align with the future reactive reducers envisioned in: https://github.com/clockworklabs/SpacetimeDBPrivate/pull/2862 This change would also be an additive change. Also please add any new syntax we go with to the |
Closes: #4571 - The secondary issue specifically
Description of Changes
spacetime.schedule(table, reducerOrProcedure)API avoids forcing tables to import reducerstable({ scheduled })table({ scheduled })path workingScheduleAtcolumn tracking onto table metadataOther Options Considered
scheduled: 'reducerName'string/name intable(...)API and ABI breaking changes
spacetime.schedule(table, reducerOrProcedure)table({ scheduled })behaviorExpected complexity level and risk
3 - Preserving legacy scheduled table behavior while changing how schedule metadata is assembled
Testing