Skip to content

Commit

Permalink
Expose reconciler hooks on servesession (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber authored Jul 17, 2023
1 parent 8662d22 commit 4915477
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugin/src/App/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function App:startSession()
end)
end)

serveSession:onPatchApplied(function(patch, unapplied)
serveSession:hookPostcommit(function(patch, _instanceMap, unapplied)
local now = os.time()
local old = self.state.patchData

Expand Down
16 changes: 6 additions & 10 deletions plugin/src/ServeSession.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ function ServeSession.new(options)
__instanceMap = instanceMap,
__changeBatcher = changeBatcher,
__statusChangedCallback = nil,
__patchAppliedCallback = nil,
__connections = connections,
}

Expand Down Expand Up @@ -129,8 +128,12 @@ function ServeSession:setConfirmCallback(callback)
self.__userConfirmCallback = callback
end

function ServeSession:onPatchApplied(callback)
self.__patchAppliedCallback = callback
function ServeSession:hookPrecommit(callback)
return self.__reconciler:hookPrecommit(callback)
end

function ServeSession:hookPostcommit(callback)
return self.__reconciler:hookPostcommit(callback)
end

function ServeSession:start()
Expand Down Expand Up @@ -291,9 +294,6 @@ function ServeSession:__initialSync(serverInfo)
Log.warn("Could not apply all changes requested by the Rojo server:\n{}",
PatchSet.humanSummary(self.__instanceMap, unappliedPatch))
end
if self.__patchAppliedCallback then
pcall(self.__patchAppliedCallback, catchUpPatch, unappliedPatch)
end
end
end)
end
Expand All @@ -318,10 +318,6 @@ function ServeSession:__mainSyncLoop()
Log.warn("Could not apply all changes requested by the Rojo server:\n{}",
PatchSet.humanSummary(self.__instanceMap, unappliedPatch))
end

if self.__patchAppliedCallback then
pcall(self.__patchAppliedCallback, message, unappliedPatch)
end
end
end):await()

Expand Down

0 comments on commit 4915477

Please sign in to comment.