Skip to content

Commit

Permalink
Override some default configuration values.
Browse files Browse the repository at this point in the history
  • Loading branch information
howmanysmall committed Oct 23, 2021
1 parent 8409ecd commit 91a1d6f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
60 changes: 31 additions & 29 deletions src/Component/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local function UpdateRedrawComponent()
debug.profilebegin("WillRedraw-" .. ComponentName)
local WillRedraw = Component.WillRedraw
if WillRedraw then
WillRedraw:Fire(...)
WillRedraw:Fire(Component, ...)
end

debug.profileend()
Expand All @@ -34,7 +34,7 @@ local function UpdateRedrawComponent()
debug.profilebegin("DidRedraw-" .. ComponentName)
local DidRedraw = Component.DidRedraw
if DidRedraw then
DidRedraw:Fire(...)
DidRedraw:Fire(Component, ...)
end

debug.profileend()
Expand All @@ -43,13 +43,13 @@ local function UpdateRedrawComponent()
function RedrawComponent(Component, ...)
local WillRedraw = Component.WillRedraw
if WillRedraw then
WillRedraw:Fire(...)
WillRedraw:Fire(Component, ...)
end

Component:Redraw(Component.GetReducedState(), ...)
local DidRedraw = Component.DidRedraw
if DidRedraw then
DidRedraw:Fire(...)
DidRedraw:Fire(Component, ...)
end
end
end
Expand All @@ -59,26 +59,28 @@ UpdateRedrawComponent()

local function GetBindingHandler(Queue)
return function(...)
BindingHandlerActive[Queue] = true
local RequeueNextFrame = {}
local Handled = {}

local Component = next(Queue)
while Component do
Queue[Component] = nil
if Handled[Component] then
RequeueNextFrame[Component] = true
else
Handled[Component] = true
task.spawn(RedrawComponent, Component, ...)
end
if Component then
BindingHandlerActive[Queue] = true
local RequeueNextFrame = {}
local Handled = {}

while Component do
Queue[Component] = nil
if Handled[Component] then
RequeueNextFrame[Component] = true
else
Handled[Component] = true
task.spawn(RedrawComponent, Component, ...)
end

Component = next(Queue)
end
Component = next(Queue)
end

BindingHandlerActive[Queue] = false
for RequeueComponent in next, RequeueNextFrame do
Queue[RequeueComponent] = true
BindingHandlerActive[Queue] = false
for RequeueComponent in next, RequeueNextFrame do
Queue[RequeueComponent] = true
end
end
end
end
Expand Down Expand Up @@ -746,11 +748,11 @@ function ComponentStaticMetatable:__newindex(Index, Value)
end
end

local POSSIBLE_LIFECYCLE_EVENTS = {
Destroyed = true;
Destroying = true;
DidRedraw = true;
WillRedraw = true;
local DEFAULT_LIFECYCLE_EVENTS = {
Destroyed = false;
Destroying = false;
DidRedraw = false;
WillRedraw = false;
}

--[=[
Expand Down Expand Up @@ -791,7 +793,7 @@ function Component.Extend(ClassName: string, PossibleLifecycleEventsToCreate: Po
return ClassName
end

local LifecycleEventsToCreate = PossibleLifecycleEventsToCreate or POSSIBLE_LIFECYCLE_EVENTS
local LifecycleEventsToCreate = PossibleLifecycleEventsToCreate or DEFAULT_LIFECYCLE_EVENTS

function ComponentStatics.new(ComponentStore, ...)
local self = setmetatable({}, ComponentMetatable)
Expand Down Expand Up @@ -829,7 +831,7 @@ function Component.Extend(ClassName: string, PossibleLifecycleEventsToCreate: Po
function ComponentStatics:Destroy()
local Destroying = self.Destroying
if Destroying then
Destroying:Fire()
Destroying:Fire(Component)
end

self.Janitor:Destroy()
Expand All @@ -841,7 +843,7 @@ function Component.Extend(ClassName: string, PossibleLifecycleEventsToCreate: Po

local Destroyed = self.Destroyed
if Destroyed then
Destroyed:Fire()
Destroyed:Fire(Component)
Destroyed:Destroy()
end

Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local DEFAULT_CONFIGURATION = {
RunTypeChecking = false;

-- Runs an assert check when QueueRedraw is called to validate that a component's RedrawBinding is correct.
SafeRedrawCheck = true;
SafeRedrawCheck = false;

-- Enables using the V2 version of CombineReducers.
UseCombineReducersV2 = true;
Expand Down

0 comments on commit 91a1d6f

Please sign in to comment.