Optimistic / offline mutation queues
Reflect accepted mutations immediately in a runtime snapshot while their delivery is pending. Offline queues, retries, and rollback paths let the application show progress without treating an optimistic change as a confirmed backend commit.
What you configure
- online / setOnline
- Communicate application connectivity to the workflow.
- autoFlush / flush
- Use automatic flushing or explicitly control delivery.
- persistQueue / maxAttempts
- Provide queue persistence and a retry ceiling appropriate to your transport.
Essential integration
This assumes the shared Quick start already provides premiumLicense and, for UI views, premiumCalendarOptions. Only the feature-specific setup is shown.
import { EnterpriseCalendarWorkflow } from '@wts-calendar/core/enterprise-workflow';
import type { WtsCalendar } from '@wts-calendar/core';
const workflow = new EnterpriseCalendarWorkflow({
license: premiumLicense,
actor: { id: 'editor-1', roles: ['editor'] },
online: false,
autoFlush: false,
events: [
{
id: 'release',
title: 'Release window',
start: '2026-09-07T09:00:00Z',
end: '2026-09-07T10:00:00Z',
},
],
defaultPermission: 'deny',
permissionPolicies: [
{
id: 'editor-update',
effect: 'allow',
actions: ['update', 'flush'],
roles: ['editor'],
},
],
});
await workflow.submit({
type: 'update',
eventId: 'release',
changes: { title: 'Optimistic title' },
});
console.log(workflow.getMutationQueue(), workflow.getEvent('release'));
// Render optimistic records through an existing web-calendar controller.
export function bindCalendar(calendar: Pick<WtsCalendar, 'setEvents'>) {
const render = () =>
calendar.setEvents(workflow.getEvents().map((record) => ({ ...record.event })));
render();
const unsubscribe = workflow.subscribe(render);
return unsubscribe; // Call during unmount; do not leak listeners.
}
export async function reconnect(signal: AbortSignal) {
workflow.setOnline(true);
return workflow.flush({ signal });
}Behavior and lifecycle
- Only one unsettled mutation per event is allowed, preventing ambiguous rollback order.
- Conflict, rejection, cancellation, or exhausted retry paths restore the captured pre-mutation record.
Limits and responsibilities
- An in-memory queue does not survive reloads unless your application supplies suitable persistence and recovery handling.
- Offline operation does not bypass approvals, permissions, or server-side concurrency checks.
Enable this capability
- Optional module
- @wts-calendar/core/enterprise-workflow
- Local capability ID
- enterprise-workflow · enabled by package-wide Premium
Use the request form to describe your project and deployment origins. Pricing and terms are confirmed privately. A WTS license is separate from provider credentials; do not send passwords or production access tokens.
The live example uses a browser-visible deployment key restricted to this package and approved origins. It does not collect license keys or visitor credentials.