Skip to content

Commit

Permalink
Trigger action and filter at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
OrlaM committed Mar 8, 2024
1 parent d57bd6e commit 4b99144
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,13 @@ public final class EventQueue<QueueEventType: Hashable> {
isProcessingActions = true
defer { isProcessingActions = false }

for enqueued in actions where allDependenciesSatisified(enqueued) {
enqueued.action()
actions = actions.filter { enqueued in
let dependenciesSatisfied = allDependenciesSatisified(enqueued)
if dependenciesSatisfied {
enqueued.action()
}
return !dependenciesSatisfied
}
actions = actions.filter { !allDependenciesSatisified($0) }
}

private func allDependenciesSatisified(_ action: EnqueuedAction) -> Bool {
Expand Down

0 comments on commit 4b99144

Please sign in to comment.