i am using ReSwift in my project to get a nice and clean redux architecture.
As i am not interested in the whole state i just subscribe to two substates for my viewcontroller:
extension ViewController: StoreSubscriber {
override func viewWillAppear(_ animated: Bool) {
store.subscribe(self) {
$0.select {
($0.subStateA, $0.subStateB)
}
}
}
override func viewWillDisappear(_ animated: Bool) {
store.unsubscribe(self)
}
func newState(state: (subStateA: SubStateA, subStateB: SubStateB)) {
print("test")
}
}
What happens:
My newState method is called every time any update happens to the store.
For example if i update subStateC it still triggers
func newState(state: (subStateA: SubStateA, subStateB: SubStateB)) {}
Can anybody explain why this happens?
Thanks and Greetings!