Interface CompilationProgress

Thenable controller for a compilation request.

Used to listen to events during compilation, and can be awaited to retrieve the compiled FlatZinc.

interface CompilationProgress {
    cancel(): void;
    isRunning(): boolean;
    off<T>(event: string, callback: ((e: T) => void)): void;
    on(event: "statistics", callback: ((e: StatisticsMessage) => void)): void;
    on(event: "trace", callback: ((e: TraceMessage) => void)): void;
    on(event: "error", callback: ((e: ErrorMessage) => void)): void;
    on(event: "warning", callback: ((e: WarningMessage) => void)): void;
    on(event: "exit", callback: ((e: ExitMessage) => void)): void;
    on(event: string, callback: ((e: object) => void)): void;
}

Hierarchy

  • PromiseLike<string>
    • CompilationProgress

Methods

  • Cancel compilation.

    Returns void

    const compile = model.compile({
    solver: 'gecode'
    });
    setTimeout(() => {
    if (compile.isRunning()) {
    compile.cancel();
    }
    }, 10000);
  • Return whether or not compilation is still in progress.

    Returns boolean

    const compile = model.compile({
    solver: 'gecode'
    });
    setInterval(() => {
    if (compile.isRunning()) {
    console.log('Still running');
    }
    }, 1000)
  • Stop listening for an event.

    Type Parameters

    • T

    Parameters

    • event: string
    • callback: ((e: T) => void)
        • (e): void
        • Parameters

          Returns void

    Returns void

    const compile = model.compile({
    solver: 'gecode',
    statistics: true
    });
    const onStat = e => {
    console.log(e.output);
    };
    // Start listening
    compile.on('statistics', onStat);
    setTimeout(() => {
    // Stop listening
    compile.off('statistics', onStat);
    }, 1000);
  • Listen for an event.

    Parameters

    Returns void

    const compile = model.compile({
    solver: 'gecode',
    statistics: true
    });
    solve.on('statistics', e => {
    console.log(e.statistics);
    });
  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • event: string
    • callback: ((e: object) => void)
        • (e): void
        • Parameters

          • e: object

          Returns void

    Returns void