MCPcopy Create free account
hub / github.com/editablejs/editable / callbackHandler

Function callbackHandler

packages/yjs-websocket/src/server/callback.ts:12–32  ·  view source on GitHub ↗
(doc: WSSharedDoc, options: CallbackOptions)

Source from the content-addressed store, hash-verified

10}
11
12const callbackHandler = (doc: WSSharedDoc, options: CallbackOptions) => {
13 const { action, timeout = 5000, objects = {} } = options
14 const room = doc.name
15 const dataToSend: Record<string, any> = {
16 room,
17 data: {},
18 }
19 const sharedObjectList = Object.keys(objects)
20 sharedObjectList.forEach(sharedObjectName => {
21 const sharedObjectType = objects[sharedObjectName]
22 dataToSend.data[sharedObjectName] = {
23 type: sharedObjectType,
24 content: getContent(sharedObjectName, sharedObjectType, doc)?.toJSON() || {},
25 }
26 })
27 if (typeof action === 'function') {
28 action(dataToSend)
29 } else {
30 callbackRequest(action, timeout, dataToSend)
31 }
32}
33
34const callbackRequest = (url: URL, timeout: number, data: any) => {
35 data = JSON.stringify(data)

Callers 1

constructorMethod · 0.90

Calls 3

getContentFunction · 0.85
callbackRequestFunction · 0.85
toJSONMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…