Skip to content

docs: document TypeScript onSchedule reducer/procedure registration - #5728

Open
cloutiertyler wants to merge 3 commits into
masterfrom
docs/typescript-onschedule
Open

docs: document TypeScript onSchedule reducer/procedure registration#5728
cloutiertyler wants to merge 3 commits into
masterfrom
docs/typescript-onschedule

Conversation

@cloutiertyler

Copy link
Copy Markdown
Contributor

Description of Changes

#5435 added the onSchedule option to reducer() and procedure() in the TypeScript bindings, but it was never documented. This PR documents it in the current (next) docs:

  • Schedule Tables (00500-schedule-tables.md): the TypeScript tab now leads with onSchedule as the recommended registration form, explains that it removes the table→reducer forward reference (so the table and its scheduled function can live in separate files without an import cycle), notes the at-most-one-scheduled-function-per-table constraint, and demotes the legacy scheduled: (): any => reducerName table option to a legacy callout.
  • Scheduling Procedures (00300-reducers.md): example switched to procedure({ onSchedule }, params, t.unit(), fn), with a note that a scheduled procedure must return t.unit().
  • Cheat sheet and Reducer Context: TypeScript examples updated to the new syntax.

migrating-to-2.0.md intentionally keeps the legacy syntax since it documents the historical migration path.

Testing

  • pnpm build in docs/ succeeds

Closes nothing; follow-up documentation for #5435.

…5435)

Document the additive schedule registration API from #5435:

- Schedule Tables: lead the TypeScript example with onSchedule, note the
  one-scheduled-function-per-table constraint and file-splitting benefit,
  and demote the scheduled table-option thunk to a legacy callout
- Scheduling Procedures: switch the example to
  procedure({ onSchedule }, ...) and note the t.unit() return requirement
- Cheat sheet and reducer-context examples updated to the new syntax

migrating-to-2.0 intentionally keeps the legacy syntax.
@clockwork-labs-bot

Copy link
Copy Markdown
Contributor

Docs review: no blocking findings.

The new examples match the TypeScript implementation: reducer({ onSchedule }, params, fn) and procedure({ onSchedule }, params, t.unit(), fn) are supported, and the existing TS tests cover the relevant schedule cases, including duplicate schedule bindings, missing ScheduleAt, and the scheduled procedure t.unit() return constraint.

I also verified locally on the PR head that pnpm build succeeds from docs/ after installing dependencies in a temporary worktree.

One non-blocking docs nit: the lead TypeScript example in schedule-tables.md now recommends onSchedule, but the snippet still starts after spacetimedb would have been defined. Adding the imports plus const spacetimedb = schema({ reminder }); export default spacetimedb; would make the recommended example copy/pasteable. This was already true before this PR, so I would not block on it.

Add imports and schema setup so the recommended schedule-tables
example is copy/pasteable, per review.
@cloutiertyler

Copy link
Copy Markdown
Contributor Author

Addressed the docs nit in ef42cfc: the lead onSchedule example in schedule-tables.md now includes the imports and const spacetimedb = schema({ reminder }); export default spacetimedb; setup, so it's copy/pasteable as-is. Docs build verified passing.

@JasonAtClockwork JasonAtClockwork left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cloutiertyler
cloutiertyler added this pull request to the merge queue Aug 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 12, 2026
@clockwork-labs-bot
clockwork-labs-bot added this pull request to the merge queue Aug 12, 2026
@joshua-spacetime
joshua-spacetime removed this pull request from the merge queue due to the queue being cleared Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants