Implement viewControllerWillUpdate and viewControllerDidUpdate in ViewController
cipolleschi opened this issue · 1 comments
cipolleschi commented
Issue
While working with tempura and VC, it happend several times that, when overriding the update(with state:)
method we forgot to call super.update(with:)
Without that invocation, the view will not receive the new VM and the view's update(oldState:)
method is not invoked.
Proposed solution
In the VC, change the update(with state:)
in something like:
func update(with state: State) {
viewControllerWillUpdate(with: state)
// current update implementation
viewControllerDidUpdate(with: state)
}
In the App's VC, the developer should override the methods vcWillUpdate(with: state)
and vcDidUpdate(with: state)
instead of the update(with state: State)
.
In this way is impossible to forget to pass the updated ViewModel to the View.
smaramba commented
done in version 0.6.0
.
The ViewController has willUpdate()
and didUpdate()
methods.