mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-26 23:56:32 +00:00
Add support for computing property and name changes in hydration patch computation
This commit is contained in:
@@ -9,6 +9,7 @@ local t = require(script.Parent.Parent.t)
|
|||||||
local InstanceMap = require(script.Parent.InstanceMap)
|
local InstanceMap = require(script.Parent.InstanceMap)
|
||||||
local Types = require(script.Parent.Types)
|
local Types = require(script.Parent.Types)
|
||||||
local invariant = require(script.Parent.invariant)
|
local invariant = require(script.Parent.invariant)
|
||||||
|
local getCanonicalProperty = require(script.Parent.getCanonicalProperty)
|
||||||
local setCanonicalProperty = require(script.Parent.setCanonicalProperty)
|
local setCanonicalProperty = require(script.Parent.setCanonicalProperty)
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -287,8 +288,36 @@ function Reconciler:__hydrateInternal(apiInstances, id, instance, hydratePatch)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: Measure differences in properties and add them to
|
local changedName = nil
|
||||||
-- hydratePatch.updates
|
local changedProperties = {}
|
||||||
|
|
||||||
|
if apiInstance.Name ~= instance.Name then
|
||||||
|
changedName = apiInstance.Name
|
||||||
|
end
|
||||||
|
|
||||||
|
for propertyName, virtualValue in pairs(apiInstance.Properties) do
|
||||||
|
local success, existingValue = getCanonicalProperty(instance, propertyName)
|
||||||
|
|
||||||
|
if success then
|
||||||
|
local decodedValue = self:__decodeApiValue(virtualValue)
|
||||||
|
|
||||||
|
if existingValue ~= decodedValue then
|
||||||
|
changedProperties[propertyName] = virtualValue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If any properties differed from the virtual instance we read, add it to
|
||||||
|
-- the hydrate patch so that we can catch up.
|
||||||
|
if changedName ~= nil or next(changedProperties) ~= nil then
|
||||||
|
table.insert(hydratePatch.updated, {
|
||||||
|
id = id,
|
||||||
|
changedName = changedName,
|
||||||
|
changedClassName = nil,
|
||||||
|
changedProperties = changedProperties,
|
||||||
|
changedMetadata = nil,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
local existingChildren = instance:GetChildren()
|
local existingChildren = instance:GetChildren()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user