# AsyncPivotEngine (@salmonui/pivot-table/engine)

> The AsyncPivotEngine interface of @salmonui/pivot-table/engine: The window-based engine running in a Worker; every call resolves once the worker is done.

Canonical: https://salmonui.dev/docs/reference/pivot-table/engine/AsyncPivotEngine

```ts
import type { AsyncPivotEngine } from '@salmonui/pivot-table/engine';
```

Entry index: https://salmonui.dev/docs/reference/pivot-table/engine (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/pivot-table/engine.md).

## Reference

Kind: interface

```ts
interface AsyncPivotEngine {
    readonly ready: Promise<PivotSummary>;
    subscribe(listener: () => void): () => void;
    getSnapshot(): PivotSummary | null;
    getStatus(): PivotComputeStatus;
    getModel(): PivotModel;
    setModel(input: PivotModelInput | ((model: PivotModel) => PivotModelInput)): Promise<PivotSummary>;
    setData(rows: readonly unknown[]): Promise<PivotSummary>;
    expand(path: PivotMemberPath): Promise<PivotSummary>;
    collapse(path: PivotMemberPath): Promise<PivotSummary>;
    expandAll(axis?: 'rows' | 'columns'): Promise<PivotSummary>;
    collapseAll(axis?: 'rows' | 'columns'): Promise<PivotSummary>;
    refresh(): Promise<PivotSummary>;
    getWindow(request: PivotWindowRequest): Promise<PivotWindow>;
    getFields(): Promise<readonly PivotFieldInfo[]>;
    getMembers(field: string, options?: {
        readonly search?: string;
        readonly limit?: number;
    }): Promise<readonly PivotMember[]>;
    drillThrough(rowIndex: number, columnIndex: number): Promise<readonly unknown[]>;
    getRawRows(indexes: readonly number[]): Promise<readonly unknown[]>;
    destroy(): void;
}
```

The window-based engine running in a Worker; every call resolves once the worker is done.

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ready` | `readonly ready: Promise<PivotSummary>;` |  | Resolves with the first result summary. |
| `subscribe` | `subscribe(listener: () => void): () => void;` |  |  |
| `getSnapshot` | `getSnapshot(): PivotSummary \| null;` |  | The latest summary (null until ready). |
| `getStatus` | `getStatus(): PivotComputeStatus;` |  |  |
| `getModel` | `getModel(): PivotModel;` |  | The latest model requested (applied optimistically). |
| `setModel` | `setModel(input: PivotModelInput \| ((model: PivotModel) => PivotModelInput)): Promise<PivotSummary>;` |  |  |
| `setData` | `setData(rows: readonly unknown[]): Promise<PivotSummary>;` |  |  |
| `expand` | `expand(path: PivotMemberPath): Promise<PivotSummary>;` |  |  |
| `collapse` | `collapse(path: PivotMemberPath): Promise<PivotSummary>;` |  |  |
| `expandAll` | `expandAll(axis?: 'rows' \| 'columns'): Promise<PivotSummary>;` |  |  |
| `collapseAll` | `collapseAll(axis?: 'rows' \| 'columns'): Promise<PivotSummary>;` |  |  |
| `refresh` | `refresh(): Promise<PivotSummary>;` |  |  |
| `getWindow` | `getWindow(request: PivotWindowRequest): Promise<PivotWindow>;` |  |  |
| `getFields` | `getFields(): Promise<readonly PivotFieldInfo[]>;` |  |  |
| `getMembers` | `getMembers(field: string, options?: {     readonly search?: string;     readonly limit?: number; }): Promise<readonly PivotMember[]>;` |  |  |
| `drillThrough` | `drillThrough(rowIndex: number, columnIndex: number): Promise<readonly unknown[]>;` |  |  |
| `getRawRows` | `getRawRows(indexes: readonly number[]): Promise<readonly unknown[]>;` |  |  |
| `destroy` | `destroy(): void;` |  | Rejects pending calls and terminates the worker. |
