MCPcopy Create free account
hub / github.com/apitable/apitable / ResourceService

Class ResourceService

packages/widget-sdk/src/resource/service.ts:66–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64};
65
66export class ResourceService implements IResourceService {
67 socket!: SocketIOClient.Socket;
68 roomService!: RoomService;
69 initialized?: boolean;
70 undoManager!: UndoManager;
71 resourceStashManager!: ResourceStashManager;
72 opEventManager: OPEventManager;
73 computeRefManager: ComputeRefManager;
74 reportSocketError = true;
75 roomIOClear = true;
76 roomLastSendTime?: number;
77 firstRoomInit = true;
78 private database!: databus.Database;
79 private databus: databus.DataBus;
80 currentResource: databus.Datasheet | undefined;
81
82 /**
83 * @deprecated This is a temporary member. All dependencies of CommandManager in the front-end will be removed in the future.
84 */
85 readonly commandManager: CollaCommandManager;
86
87 constructor(
88 public store: Store<IReduxState>,
89 public onError: IServiceError
90 ) {
91 this.opEventManager = new OPEventManager({
92 options: {
93 enableVirtualEvent: true,
94 // enableCombEvent: true, // The client does not need to enable aggregated events.
95 },
96 // eslint-disable-next-line require-await
97 getState: () => {
98 return store.getState();
99 },
100 op2Event: new OP2Event(clientWatchedEvents),
101 });
102 this.computeRefManager = new ComputeRefManager();
103 this.databus = this.createDataBus();
104 this.commandManager = this.createCommandManager();
105 }
106
107 init() {
108 if (this.initialized) {
109 console.error('Do not repeat the initialization of the datasheet store.');
110 return;
111 }
112 this.initialized = true;
113
114 this.bindBeforeUnload();
115 this.socket = this.createSocket();
116 this.database = this.createDatabase();
117 this.resourceStashManager = new ResourceStashManager(this.store, () => {
118 return this.roomService;
119 });
120 }
121
122 destroy() {
123 if (!this.initialized) {

Callers

nothing calls this directly

Calls 6

getCollaEngineMethod · 0.95
applyOperationsMethod · 0.95
tFunction · 0.90
syncOperationsMethod · 0.80
isSafeToCloseMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected