Title: Focus ReSwift reducers to one state change ID: 201801041611 Tags: #reswift #srp
ReSwift reducers should not have conditional side-effects, changing different states out of convenience. That makes it hard to notice which action changed what. The condition is most of the problem, I think.
An ideal approach would be to have 1 reducer/action pair for each substate change.
When reducers overlap (they touch the same state), this can become a problem. (IncreaseCounter
and DecreaseCounter
are a bad example.) Conditional changes to another substate should be extracted as another action which is dispatched by a Middleware under similar circumstances.