/// import { Default, handler, NAME, pattern, Stream, UI, Writable, } from "commontools"; interface State { data: Default; counter: Default; } interface WritableState { data: Writable>; counter: Writable>; } interface Output { data: string; counter: number; updateData: Stream; } const updateData = handler((_event, state) => { const newCount = (state.counter.get() ?? 0) + 1; state.counter.set(newCount); state.data.set(`Updated data #${newCount} - ${new Date().toISOString()}`); }); export default pattern((state) => { return { [NAME]: "Autosave Test", [UI]: (

Autosave Test Pattern

Data: {state.data}

Counter: {state.counter}

Update Data Download (Option+click for autosave) No Autosave Button

Test Instructions:

  1. Click "Download" normally to test regular download
  2. Option+click (Alt+click) on the PRIMARY button to enable autosave (will open folder picker)
  3. Option+click on "No Autosave Button" to see the shake feedback
  4. After enabling autosave, click "Update Data" to see the pending indicator (amber pulsing dot)
  5. Option+click again on the PRIMARY button to disable autosave
), data: state.data, counter: state.counter, updateData: updateData(state), }; });