Skip to content

Commit

Permalink
Allow Roact Bindings to skip property updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyseph committed Jul 21, 2022
1 parent 956891b commit 53272ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/PropMarkers/Constant.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local Symbol = require(script.Parent.Parent.Symbol)

local Constant = {
SkipBindingUpdate = Symbol.named("SkipBindingUpdate"),
}

return Constant
5 changes: 5 additions & 0 deletions src/RobloxRenderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local ElementKind = require(script.Parent.ElementKind)
local SingleEventManager = require(script.Parent.SingleEventManager)
local getDefaultInstanceProperty = require(script.Parent.getDefaultInstanceProperty)
local Ref = require(script.Parent.PropMarkers.Ref)
local Constant = require(script.Parent.PropMarkers.Constant)
local Type = require(script.Parent.Type)
local internalAssert = require(script.Parent.internalAssert)

Expand Down Expand Up @@ -69,6 +70,10 @@ end

local function attachBinding(virtualNode, key, newBinding)
local function updateBoundProperty(newValue)
if newValue == Constant.SkipBindingUpdate then
return
end

local success, errorMessage = xpcall(function()
setRobloxInstanceProperty(virtualNode.hostObject, key, newValue)
end, identity)
Expand Down
1 change: 1 addition & 0 deletions src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local Roact = strict({
Change = require(script.PropMarkers.Change),
Children = require(script.PropMarkers.Children),
Event = require(script.PropMarkers.Event),
Constant = require(script.PropMarkers.Constant),
Ref = require(script.PropMarkers.Ref),

mount = robloxReconciler.mountVirtualTree,
Expand Down

0 comments on commit 53272ef

Please sign in to comment.