UNPKG

1.24 kBTypeScriptView Raw
1import { Disposable, TextEditor, TextEditorElement } from "../index";
2
3/**
4 * ViewRegistry handles the association between model and view types in Atom.
5 * We call this association a View Provider. As in, for a given model, this class
6 * can provide a view via ::getView, as long as the model/view association was
7 * registered via ::addViewProvider.
8 */
9export interface ViewRegistry {
10 /**
11 * Add a provider that will be used to construct views in the workspace's view
12 * layer based on model objects in its model layer.
13 */
14 addViewProvider(createView: (model: object) => HTMLElement | undefined): Disposable;
15 /**
16 * Add a provider that will be used to construct views in the workspace's view
17 * layer based on model objects in its model layer.
18 */
19 // tslint:disable-next-line:no-any
20 addViewProvider<T>(
21 modelConstructor: { new(...args: any[]): T }, // tslint:disable-line no-any
22 createView: (instance: T) => HTMLElement | undefined,
23 ): Disposable;
24
25 /** Get the view associated with an object in the workspace. */
26 getView(obj: TextEditor): TextEditorElement;
27 getView(obj: object): HTMLElement;
28}
29
30export interface ViewModel {
31 getTitle: () => string;
32}