mirror of
https://github.com/cudr/slate-collaborative.git
synced 2024-10-27 20:34:06 +00:00
feat: make socket available for onTrace callback
This commit is contained in:
parent
d5b15e1279
commit
a7fbd9ba9c
@ -19,6 +19,7 @@ export interface IAutomergeMetaData {
|
|||||||
|
|
||||||
export type ITraceFunction = (
|
export type ITraceFunction = (
|
||||||
metaData: IAutomergeMetaData,
|
metaData: IAutomergeMetaData,
|
||||||
|
socket: SocketIO.Socket,
|
||||||
computationFunction: () => void
|
computationFunction: () => void
|
||||||
) => void
|
) => void
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ export interface IAutomergeCollaborationOptions {
|
|||||||
onTrace?: ITraceFunction
|
onTrace?: ITraceFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOnTrace: ITraceFunction = (metaData, computation) => {
|
const defaultOnTrace: ITraceFunction = (metaData, socket, computation) => {
|
||||||
computation()
|
computation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ export default class AutomergeCollaboration {
|
|||||||
docId
|
docId
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onTrace(metaData, () => {
|
this.onTrace(metaData, socket, () => {
|
||||||
// Emit the socket message needed for receiving the automerge document
|
// Emit the socket message needed for receiving the automerge document
|
||||||
// on connect and reconnect
|
// on connect and reconnect
|
||||||
socket.emit('msg', {
|
socket.emit('msg', {
|
||||||
@ -254,7 +255,7 @@ export default class AutomergeCollaboration {
|
|||||||
opCount: collabActions.length
|
opCount: collabActions.length
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onTrace(metaData, () => {
|
this.onTrace(metaData, socket, () => {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'operation':
|
case 'operation':
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user