     func dispatch(_ action: Action, trace: Trace = Trace()) {
         let context = Context(trace: trace)
         var effects: [Effect] = []
-        work.sync {
-            middlewares.forEach { middleware in
-                effects += send { try middleware.apply(action: action, context: context) }
-            }
-            states.forEach { state in
-                effects += send {
-                    try state.apply(action: action, context: context, reducers: reducers, observers: observers, middlewares: middlewares)
-                }
+        middlewares.forEach { middleware in
+            effects += send { try middleware.apply(action: action, context: context) }
+        }
+        states.forEach { state in
+            effects += send {
+                try state.apply(action: action, context: context, reducers: reducers, observers: observers, middlewares: middlewares)
             }
         }
         process(effects)

    
    func add(middleware: Middleware) -> Any {
        let box = middleware.box
        work.sync {
            weakMiddlewares.append { [weak box] in box }
        }
        return box
    }
    
    func subscribe<S: State>(priority: Priority = .normal, observer: @escaping Observer<S>) -> Any {
        let box = ObserverBox(priority: priority, observer: observer)
        work.sync {
            weakObservers.append { [weak box] in box }
        }
        var effects: [Effect] = []
        states.forEach { state in
            effects += send { try state.apply(observer: observer) }

        return states.count + reducers.count + observers.count
    }

  func add<S: State>(state: S) -> Any {
        let box = StateBox(state: state)
        weakStates.append { [weak box] in box }
        var effects: [Effect] = []
        observers.forEach { observer in
            effects += send { try observer.apply(state: state) }
