Skip to content

Commit

Permalink
Fix hooks more.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hekili committed Sep 22, 2024
1 parent 468c13a commit 73c7f7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions Classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6109,16 +6109,27 @@ end

do
local inProgress = {}
local vars = {}

ns.callHook = function( hook, ... )
if not class.hooks[ hook ] or inProgress[ hook ] then return ... end
local vars = { ... }
local function load_args( ... )
local count = select( "#", ... )
if count == 0 then return end

inProgress[ hook ] = true
for _, h in ipairs( class.hooks[ hook ] ) do
vars = { h( unpack( vars ) ) }
for i = 1, count do
vars[ i ] = select( i, ... )
end
inProgress[ hook ] = nil
end

ns.callHook = function( event, ... )
if not class.hooks[ event ] or inProgress[ event ] then return ... end
wipe( vars )
load_args( ... )

inProgress[ event ] = true
for i, hook in ipairs( class.hooks[ event ] ) do
load_args( hook( unpack( vars ) ) )
end
inProgress[ event ] = nil

return unpack( vars )
end
Expand Down
2 changes: 1 addition & 1 deletion State.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6909,7 +6909,7 @@ function state.advance( time )
end
end ]]

ns.callHook( "advance_end", time )
time = ns.callHook( "advance_end", time ) or time

return time
end
Expand Down

0 comments on commit 73c7f7b

Please sign in to comment.