2021-05-31 01:59 PM
Hi,
I would like to ask as I never saw any effective example, how could I effectively update a lot of information from backend to frontend.
Lets assume I have 40 variables of difetent types for example uint16_t, int8_t, bool, is there any effective way to implement this?
For now I can only imagine creating queue for every variable type, then sending it to model and calling proper presenter functions.
Also is there any way to effective implement presenter and view functions instead of making function for each variable?
Thank you!
2021-05-31 11:58 PM
Hello AFire.1,
I think you could create a struct that has all your different variables stored inside.
This way you would only need to create one presenter function for the entire struct. Then in your View, when you receive your struct you can refer to each variable as myStruct.myVariable .
Hope this will help you,
Alexandre
2021-06-01 02:55 AM
Thank you for answer!
Also I wanted to ask where it is the best place to check message identifier. In model or presenter? Considering a lot of variables will repeat on multiple screens.
Should model just receive this struct and pass it to model? Then in model check this id and call proper view function?
Also is there any good practice to create some generic code for multiple View instances instead of duplicating setMyVariable() functions in each of them?
Thanks!
2021-06-01 09:33 PM
Hello AFire.1,
I'm not sure I understand what you mean by "message identifier". If writing in the model can avoid some repetition you can do it in the model. Theoretically, all the computation/processing for a View should be done in the Presenter. Model is mainly used as an interface with the backend and to save data across the entire UI.
So far there's no other practice than implementing a function for each presenter that needs to use it.
/Alexandre