Presenter / View ... which gets initialized first?
I'm trying to use the MVP system in what is hopefully a correct manner. The way I understand it, the Presenter takes the data from the Model and assembles it in a way that the View can display.
However, in the present implementation of the MVP in TouchGFX, the view is being configured before the Presenter has a chance to configure this information.
For example, when trying to implement a scroll wheel, I'm supposed to override the ScrollWheelUpdateItem as below:
void Screen2View::scrollWheel1UpdateItem(ListItem& item, int16_t itemIndex)
{
touchgfx::TypedTextId id = presenter->getParameterOptionText(itemIndex);
std::cout << "Setting text index to:" << id << std::endl;
item.setText(id);
}However, the call tree for switching to a different view is first initializing the view and *then* initializing the presenter. The following is from the TouchGFX library (MVPApplication.hpp):
static inline void finalizeTransition(Screen* newScreen, Presenter* newPresenter, Transition* newTransition)
{
newScreen->setupScreen();
newPresenter->activate();
newScreen->bindTransition(*newTransition);
newTransition->init();
Application::getInstance()->draw();
}As you can see, "setupScreen" is called *before* the presenter has been activated. Why? When the "setupScreen" is called, it's calling functions that rely on the presenter, which doesn't have the information yet. To me, it would make much more sense that lines 3&4 are swapped. Am I missing something?
Thanks,
Jeremy
