highs-js API reference
    Preparing search index...

    Type Alias HighsCallbackMap

    HighsCallbackMap: {
        readonly [T in CallbackType]?: (event: CallbackEventFor<T>) => undefined
    }

    Per-channel hooks installed for one Model.run() call.

    Use computed keys from highs.constants.callbackType; each key narrows its handler to the correct event capabilities. Omitted channels remain inactive. Registration is temporary: run() starts the selected channels, executes synchronously, then stops and unregisters them even if solving or a handler throws.

    Handlers must be synchronous and must not call model or raw methods. They may retain typed-array snapshots, update closure state, or call postMessage(). Only event controls are reentrant, and they expire when the handler returns.

    const callbacks: HighsCallbackMap = {
    [highs.constants.callbackType.mipImprovingSolution](event) {
    worker.postMessage({ solution: event.data.mip_solution });
    },
    [highs.constants.callbackType.mipLogging](event) {
    worker.postMessage({ gap: event.data.mip_gap });
    },
    [highs.constants.callbackType.mipInterrupt](event) {
    if ((event.data.mip_gap ?? Infinity) <= 0.01) event.interrupt();
    },
    };
    model.run(callbacks);