WORKER / WASM DEMO

Extend formulas without faking async work

Register host functions and let an in-flight calculation visibly remain busy until its promise resolves.

Try this

  1. Enter a custom function into a formula cell.
  2. Observe the busy state while asynchronous work is pending.
  3. Change an argument and let the worker recalculate the result.

How it works

Custom formula registration is a host-to-engine contract. The UI reflects engine state instead of inventing a client-only loading indicator, so errors and asynchronous results share one formula lifecycle.

View source

import type {
  WorkerWorkbookBackendSheet,
  WorkerWorkbookBackendSheetInput,
  WorkerWorkbookClient,
} from '@einfach/solid-excel/vnext'

export const customFormulaSheets: WorkerWorkbookBackendSheetInput[] = [
  { id: 'items', name: 'Items' },
]

function text(client: WorkerWorkbookClient, sheet: number, address: string, value: string) {
  return client.setCell(sheet, address, { type: 'text', value })
}

function number(client: WorkerWorkbookClient, sheet: number, address: string, value: number) {
  return client.setCell(sheet, address, { type: 'number', value })
}

function formula(client: WorkerWorkbookClient, sheet: number, address: string, value: string) {
  return client.setFormulaDetailed(sheet, address, value)
}

/** Seeds formula calls before the host registrations trigger engine re-evaluation. */
export async function seedCustomFormulasWorkbook(