cancel
Showing results for 
Search instead for 
Did you mean: 

I want to pass variables to some views

Ebun.1
Senior

Thank you for helping.

I want to access common variables on several screens (View).

How do I pass a variable to View?

Will it be passed to the base class of View?

I want to make it a smart way without using global variables.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

Smart is global, when you dont like global , then you create MODEL - PRESENTER - VIEW, but in real your variable master exist in MODEL as class variable, then is protected from access it on other threads . And for use in views need create setter and getter methods in every view and presenter...

View solution in original post

3 REPLIES 3
MM..1
Chief II

Smart is global, when you dont like global , then you create MODEL - PRESENTER - VIEW, but in real your variable master exist in MODEL as class variable, then is protected from access it on other threads . And for use in views need create setter and getter methods in every view and presenter...

Ebun.1
Senior

Hi MM ..1

I am always grateful for your help.

Sometimes the global is smarter, isn't it?

I will think about it.

BParh.1
Senior III

In my opinion I would not use global variable here especially for complex application. While it might be convenient, but is poor in term of localization as everything in the code can access those variables. And it doesn't scale well as it would get messier when application is getting complex.

A more sound approach is to leverage existing TouchGFX Engine architecture Model-View-Presenter

https://support.touchgfx.com/docs/development/ui-development/software-architecture/model-view-presenter-design-pattern

All the data intent to persist over the View classes mus be in model class. But in order view to reflects Model data changes, it has to go through the Presenter class.