-
-
Notifications
You must be signed in to change notification settings - Fork 127
/
asynccellrenderer.ts
53 lines (49 loc) · 1.92 KB
/
asynccellrenderer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2023, Lumino Contributors
|
| Distributed under the terms of the BSD 3-Clause License.
|
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
import { CellRenderer } from './cellrenderer';
import { GraphicsContext } from './graphicscontext';
/**
* An object which renders the cells of a data grid asynchronously.
*
* #### Notes
* For performance reason, the datagrid only paints cells synchronously,
* though if your cell renderer inherits from AsyncCellRenderer, you will
* be able to do some asynchronous work prior to painting the cell.
* See `ImageRenderer` for an example of an asynchronous renderer.
*/
export abstract class AsyncCellRenderer extends CellRenderer {
/**
* Whether the renderer is ready or not for that specific config.
* If it's not ready, the datagrid will paint the placeholder using `paintPlaceholder`.
* If it's ready, the datagrid will paint the cell synchronously using `paint`.
*
* @param config - The configuration data for the cell.
*
* @returns Whether the renderer is ready for this config or not.
*/
abstract isReady(config: CellRenderer.CellConfig): boolean;
/**
* Do any asynchronous work prior to painting this cell config.
*
* @param config - The configuration data for the cell.
*/
abstract load(config: CellRenderer.CellConfig): Promise<void>;
/**
* Paint the placeholder for a cell, waiting for the renderer to be ready.
*
* @param gc - The graphics context to use for drawing.
*
* @param config - The configuration data for the cell.
*/
abstract paintPlaceholder(
gc: GraphicsContext,
config: CellRenderer.CellConfig
): void;
}