Hey Joe,
we haven't talked about this at all yet and don't have any documentation on it, and there are a few ways to approach this. One interesting way is to create a higher-order reducer that can allow sharing actions from one reducer to another.
For example, this:
extension Reducer {
func resending<Value>(
_ case: @escaping (Value) -> Action,
to embed: @escaping (Value) -> Action
) -> Self {
.combine(
self,
.init { state, action, _ in
if let value = CasePath.case(`case`).extract(from: action) {
return Effect(value: embed(value))
} else {
return .none
}
}
)
}
}
You can tack that onto an existing reducer to make any of its action be automatically re-sent to another reducer:
parentReducer
.resending(ParentAction.fooClient, to: { ParentAction.child1(.fooClient($0)) })
.resending(ParentAction.fooClient, to: { ParentAction.child2(.fooClient($0)) })
...
I'd be curious how that fits your use case.