How to propagate an event from the ModelListener to ALL presenters without the need to repeat the action in each presenter/viewer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-22 02:44 PM
Examples presented show the declaration of an empty virtual method in the listener, and override it in the presenter. However, in the case of multiple screens and the same action will be taken, there will be multiple redundancy.
- Labels:
-
TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-23 03:13 AM
It does not make sense to propagate it to "all" presenters, because only one is active at any given time. Store the data in the model and notify the active presenter.
The thing to do here is make sure that each presenter contacts the model to update their state, so that when they're activated (activate() function), they're always up to date.
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-23 05:57 AM
Let's give an example to clarify the question: an emergency signal needs to be sent from "the rest" of the system, i.e. through the Model, and any active presenter should respond to it.
The point here is that: with an empty implementation of the propagating function, let say emergency_activate() in the modelListener, a "receiver" method has to be in each "Presenter", which calls let say activate_emergency() from the "Viewer."
What I am trying to explore here: is there a way to call the activate_emergency() from the modelListener rather than from the Presenter?
It has been mentioned in the documentation that the model has a pointer to the "active" presenter, right? If so, how can it be accessed? Can we use it to access members of the active Viewer as well?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 12:33 AM
Hi @RMoha.2​ ,
The best way, as suggested by @Martin KJELDSEN​ , is to access the view using the presenter It might sound heavy on code, but is a sound approach from a design & maintenance point of view.
/Jagdish Bisawa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 01:35 AM
It sounds like what you want is a base-class for all types of Presenters that want to get notified? So that you can define the intention to react to something just once instead of in every presenter`?
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 05:35 AM
That's exactly what would be perfect. Is this available?
An Alternative might be: does the Model maintains a pointer to the current active Presenter/Viewer? If so, how to access it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 05:44 AM
I agree with the point that is "heavy on code."
One way around it:
From TouchGFX Designer:
1- handle the action for this event in a custom container
2- make this container part of each screen. If not needed to be show, make it invisible
From Code:
1- maintain a pointer of this custom container in the Model (i.e. update this pointer in the Custom_Container::initialize() )
2- upon the event request: the Model calls the action through that pointer@
This way, the load is split between the designer and the code. Adding a new screen is seamless with the only extra step of adding the custom container.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 05:53 AM
I actually have a project here i need to finish until we can get the feature into the designer (it's slowly being discussed/designed). My project is a script that you configure with your PostGenerateCommand in the .touchgfx file - You can define BaseViews/Generators by hand or using the designer and have the script update your Generated files (The modification happens in the Base classes, so it must be a post-generate operation to update the read-only files)
I'l see if i can finish it soon and make it available.
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 05:58 AM
Sounds good, thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-26 06:46 AM
@Martin KJELDSEN​ I