MCPcopy
hub / github.com/alibaba/lowcode-engine / TransactionManager

Class TransactionManager

packages/utils/src/transaction-manager.ts:5–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import EventEmitter from 'events';
4
5class TransactionManager {
6 emitter = new EventEmitter();
7
8 executeTransaction = (fn: () => void, type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT): void => {
9 this.emitter.emit(`[${type}]startTransaction`);
10 runInAction(fn);
11 this.emitter.emit(`[${type}]endTransaction`);
12 };
13
14 onStartTransaction = (fn: () => void, type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT): () => void => {
15 this.emitter.on(`[${type}]startTransaction`, fn);
16 return () => {
17 this.emitter.off(`[${type}]startTransaction`, fn);
18 };
19 };
20
21 onEndTransaction = (fn: () => void, type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT): () => void => {
22 this.emitter.on(`[${type}]endTransaction`, fn);
23 return () => {
24 this.emitter.off(`[${type}]endTransaction`, fn);
25 };
26 };
27}
28
29export const transactionManager = new TransactionManager();

Callers

nothing calls this directly

Calls 3

emitMethod · 0.65
onMethod · 0.65
offMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…