Skip to content

MaelstromExtension

MaelstromExtension<Out> = (ctx) => Out

Defined in: packages/react/src/lib/extension-types.ts:58

Factory function that receives the extension context and returns additional fields to be merged onto the MaelstromInstance.

Extension authors implement this type to create addons (voice, analytics, devtools, etc.) and consumers apply them via instance.with(extension).

Extensions must return a plain object synchronously. Async factories, arrays, and primitive values are rejected at compile time via the ExtensionOutput constraint.

Out extends ExtensionOutput

MaelstromExtensionContext

Out

const myExtension: MaelstromExtension<{ greet: () => string }> = (ctx) => ({
greet: () => 'Hello from extension!',
});
const m = createMaelstrom({ vessels }).with(myExtension);
m.greet(); // 'Hello from extension!'