File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -95,13 +95,16 @@ public final class GatedMiddleware<M: Middleware>: Middleware {
9595 /// unwrapped versions of `getState` and `output` as properties of your concrete middleware, and set them from the arguments of this function.
9696 ///
9797 /// This will be always forwarded to the inner middleware regardless of its gate state, another reason for you to never start side-effects on this
98- /// event
98+ /// event. However, this is proxied by the gated middleware, and output will only be forwarded to the store in case the gate state is active.
9999 ///
100100 /// - Parameters:
101101 /// - getState: a closure that allows the middleware to read the current state at any point in time
102102 /// - output: an action handler that allows the middleware to dispatch new actions at any point in time
103103 public func receiveContext( getState: @escaping GetState < M . StateType > , output: AnyActionHandler < M . OutputActionType > ) {
104- middleware. receiveContext ( getState: getState, output: output)
104+ middleware. receiveContext ( getState: getState, output: . init { [ weak self] outputAction, source in
105+ guard let self = self , self . gate == . active else { return }
106+ output. dispatch ( outputAction, from: source)
107+ } )
105108 }
106109
107110 /// Handles the incoming actions and may or not start async tasks, check the latest state at any point or dispatch additional actions.
You can’t perform that action at this time.
0 commit comments