Path: blob/main/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Emitter } from '../../../../../base/common/event.js';6import { Disposable } from '../../../../../base/common/lifecycle.js';7import { NotebookCellStateChangedEvent, NotebookLayoutChangedEvent, NotebookMetadataChangedEvent, NotebookViewEvent, NotebookViewEventType } from '../notebookViewEvents.js';89export class NotebookEventDispatcher extends Disposable {10private readonly _onDidChangeLayout = this._register(new Emitter<NotebookLayoutChangedEvent>());11readonly onDidChangeLayout = this._onDidChangeLayout.event;1213private readonly _onDidChangeMetadata = this._register(new Emitter<NotebookMetadataChangedEvent>());14readonly onDidChangeMetadata = this._onDidChangeMetadata.event;1516private readonly _onDidChangeCellState = this._register(new Emitter<NotebookCellStateChangedEvent>());17readonly onDidChangeCellState = this._onDidChangeCellState.event;1819emit(events: NotebookViewEvent[]) {20for (let i = 0, len = events.length; i < len; i++) {21const e = events[i];2223switch (e.type) {24case NotebookViewEventType.LayoutChanged:25this._onDidChangeLayout.fire(e);26break;27case NotebookViewEventType.MetadataChanged:28this._onDidChangeMetadata.fire(e);29break;30case NotebookViewEventType.CellStateChanged:31this._onDidChangeCellState.fire(e);32break;33}34}35}36}37383940