Skip to content

Event Manager

AdditionalData (Extended from @revolist/revogrid)

Section titled “AdditionalData (Extended from @revolist/revogrid)”
interface AdditionalData {
/**
* Additional data property for event manager
* @deprecated Use `grid.eventManager` instead.
*
* @example
* ```typescript
* const grid = document.createElement('revo-grid');
* grid.additionalData = { eventManager: { collectEvents: true, collectEventsDelay: 1000 } };
* ```
*/
eventManager?: EventManagerConfig
}

HTMLRevoGridElement (Extended from global)

Section titled “HTMLRevoGridElement (Extended from global)”
interface HTMLRevoGridElement {
/**
* Direct event manager configuration.
*/
eventManager?: EventManagerConfig
}

HTMLRevoGridElementEventMap (Extended from global)

Section titled “HTMLRevoGridElementEventMap (Extended from global)”
interface HTMLRevoGridElementEventMap {
/**
* Event for event manager
*
* @example
* ```typescript
* grid.addEventListener(ON_EDIT_EVENT, (event) => {
* console.log(event);
* });
* ```
*/
[ON_EDIT_EVENT]: EventManagerEvent;
[BEFORE_GRID_EDIT_RESOLVE_EVENT]: EventManagerEvent
}

RevoGrid Plugin for Event Manager. Whole purpose is to collect and dispatch edit events in one place.

class EventManagerPlugin {
/**
* Adds a normalized edit produced by another plugin to EventManager's
* collection pipeline.
*/
collectEdit(detail: EventManagerEvent): void;
/** Publishes any currently batched edit before a source-schema boundary. */
flushCollectedEdits(): void;
}

A producer-defined semantic change carried by the unified edit stream.

interface EventManagerDomainChange {
readonly type: TType;
readonly detail: TDetail
}

Identifies which layer already owns applying the event payload to source.

/** Identifies which layer already owns applying the event payload to source. */
export type EventManagerSourceMutation = 'event-manager' | 'producer';

Replay-only state kept outside the ordinary grid row/field payload.

interface EventManagerHistorySnapshot {
readonly before: T;
readonly after: T
}

Keyed snapshots let independent producers compose in one history entry.

/** Keyed snapshots let independent producers compose in one history entry. */
export type EventManagerHistory = Record<string, EventManagerHistorySnapshot>;

EventManagerEvent (Extended from index.ts)

Section titled “EventManagerEvent (Extended from index.ts)”
export type EventManagerEvent<
TDomainChange extends EventManagerDomainChange = EventManagerDomainChange,
> = {
eventTypes: string[];
previousData: BeforeRangeSaveDataDetails['data'];
/** Ordered semantic changes contributed by feature plugins. */
domainChanges?: TDomainChange[];
/** Defaults to `event-manager`; producer-owned edits are observation-only. */
sourceMutation?: EventManagerSourceMutation;
/** Defaults to `true`; set to `false` to publish without creating a History entry. */
recordHistory?: boolean;
/** Domain-owned replay state. This is not applied through the grid data provider. */
history?: EventManagerHistory;
/** @internal Collection metadata for coordinates invalidated by topology changes. */
invalidatedRowIndexes?: number[];
} & Omit<BeforeRangeSaveDataDetails, 'newRange' | 'oldRange'>
& ClipboardValidationEditMetadata;

DataGridFormattingEventManagerEvent (Extended from index.ts)

Section titled “DataGridFormattingEventManagerEvent (Extended from index.ts)”

Unified EventManager entry for one formatting state transition.

/** Unified EventManager entry for one formatting state transition. */
export type DataGridFormattingEventManagerEvent = EventManagerEvent & {
historyType: 'data-grid-formatting';
formatting: {
before: DataGridFormattingRuntimeState;
after: DataGridFormattingRuntimeState;
};
};

The configuration object for the EventManagerPlugin.

/**
* The configuration object for the EventManagerPlugin.
*/
export type EventManagerConfig = {
/**
* Whether to collect events and apply delay or send them immediately.
* @default false
*/
collectEvents?: boolean;
/**
* The delay in milliseconds to wait until the
* collected events are applied to the grid.
* Used only when `collectEvents` is true.
* @default 0
*/
collectEventsDelay?: number;
/**
* Whether to apply the collected events to the
* original data source.
* @default true
*/
applyEventsToSource?: boolean;
};

Creates ordinary row/field patches only where a canonical entity retains the same source index. Creates, deletes, and reorders remain domain changes.

export function createEventManagerGridData<T extends DataType>(
options: CreateEventManagerGridDataOptions<T>,
): EventManagerGridData<T>;

interface CreateEventManagerGridDataOptions {
readonly previousRows: readonly T[];
readonly rows: readonly T[];
readonly getRowId: (row: T) => string | number | undefined;
/** Restricts comparison to canonical indexes already known to be touched. */
readonly rowIndexes?: readonly number[]
}

EventManagerGridData (Extended from index.ts)

Section titled “EventManagerGridData (Extended from index.ts)”
export type EventManagerGridData<T extends DataType = DataType> = Pick<
EventManagerEvent,
'data' | 'previousData' | 'models' | 'invalidatedRowIndexes'
> & {
readonly data: Record<number, Partial<T>>;
readonly previousData: Record<number, Partial<T>>;
readonly models: Record<number, T>;
};

Marks a history replay that was successfully applied by its source owner.

export function markEventManagerHistoryReplayHandled(
detail: HistoryReplayDetail,
historyKeys?: readonly string[],
): void;

Distinguishes successful source replay from an application replay veto.

export function isEventManagerHistoryReplayHandled(
detail: HistoryReplayDetail,
): boolean;

Runs after every keyed producer snapshot in a replay has been applied.

export function onEventManagerHistoryReplayHandled(
detail: HistoryReplayDetail,
listener: () => void,
): void;

Marks a beforeedit whose native application was taken over by EventManager.

export function markEventManagerEditIntercepted(
event: CustomEvent<BeforeSaveDataDetails>,
completeUnifiedEdit: () => void,
): void;

Distinguishes EventManager interception from a plain beforeedit veto.

export function isEventManagerEditIntercepted(detail: BeforeSaveDataDetails): boolean;

Records the cancelable unified-edit outcome for an intercepted beforeedit.

export function markEventManagerUnifiedEditOutcome(
detail: BeforeSaveDataDetails,
accepted: boolean,
): void;

Completes and returns the cancelable unified-edit outcome for a transaction.

export function completeEventManagerInterceptedEdits(
details: BeforeSaveDataDetails[],
): boolean;

export function eventManagerValuesEqual(left: unknown, right: unknown): boolean;