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, callback): void;
    on(event, callback): void;
    on(event, callback): void;
    on(event, callback): void;
    on(event, callback): void;
    on(event, callback): void;
    on(event, callback): void;
}

Hierarchy

  • PromiseLike<string>
    • CompilationProgress

Methods

  • Cancel compilation.

    Returns void

    Example

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

    Returns boolean

    Example

    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) => void)
        • (e): void
        • Parameters

          Returns void

    Returns void

    Example

    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

    • event: "statistics"
    • callback: ((e) => void)

    Returns void

    Example

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

    • event: "trace"
    • callback: ((e) => void)

    Returns void

  • Parameters

    • event: "error"
    • callback: ((e) => void)

    Returns void

  • Parameters

    • event: "warning"
    • callback: ((e) => void)

    Returns void

  • Parameters

    • event: "exit"
    • callback: ((e) => void)

    Returns void

  • Parameters

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

          • e: object

          Returns void

    Returns void