Skip to content

Commit

Permalink
Update RefdsReduxStore.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelesantos committed Apr 11, 2024
1 parent 817d7fa commit 5cca287
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Sources/RefdsRedux/RefdsReduxStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public final class RefdsReduxStore<State>: ObservableObject {

private let queue = DispatchQueue(
label: "refds.designPatterns.redux.middleware",
qos: .userInteractive,
attributes: .concurrent
qos: .userInteractive
)

public init(
Expand All @@ -24,14 +23,14 @@ public final class RefdsReduxStore<State>: ObservableObject {
}

public func dispatch(action: RefdsReduxAction) {
DispatchQueue.main.async {
DispatchQueue.main.sync {
withAnimation {
self.state = self.reducer(self.state, action)
}
}

self.middlewares.forEach { middleware in
queue.async {
queue.sync {
middleware(self.state, action, self.dispatch)
}
}
Expand Down

0 comments on commit 5cca287

Please sign in to comment.