Hi,
In the new Places/Activities paradigm, Activities are disposable objects that are constructed just-in-time when they are needed.
Views are long lived because DOM manipulations are expensive in terms of performance of your app, as per the docs.
So Activities don't keep state and Views do.
My problem :
If an Activity is making a lot of expensive server calls to fill select boxes and more and it uses this information to configure its View.
The user acts on the view and selections and text values change. This is communicated with its Activity (Presenter).
Next the user moves to a Place without this Activity/View pair present.
When later the users navigates to a place where the given Activity is present again, the changes made to the view are still present, but the Activity is a fresh copy without state.
Now I can take several roads to sync state of my Activity :
1- re-initiliaze the Activity, making all the calls again and then syncing with the View state.
2- try to reconstruct the data based on the state of the view
3- Use static functions on the Activity to keep state of appearances
4- Use a helper/singleton Manager object to keep state, which is initialized with requestfactory and clientfactory at application startup.
Each option has disadvantages ;
1- make the expensive calls again, still have to sync the Activitiy state with the View state.
2- this is a lot of code and the View becomes too heavy weight, holding too much logic
3- the problem here is that requestfactory and clientfactory are only passed to the Activity when the ActivityManager creates the Activity. I can only make the calls with a real instance, unless I break out of the standard pattern and pre-init the static part of the Activity.
4- this is working but the Activity ends up rather empty, most logic now shifts completely to the singleton object.
Did I miss something in working with Places / Activity / Views ?
How do you solve these issues ?
thx
Koen