Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to force to update widgets upon certain circumstances? #15

Closed
ValeriusGC opened this issue Aug 15, 2019 · 4 comments
Closed

How to force to update widgets upon certain circumstances? #15

ValeriusGC opened this issue Aug 15, 2019 · 4 comments

Comments

@ValeriusGC
Copy link

We have DarteaStorageKey for storing state.
But periodically one need to force to update widgets upon some circumstances.
Are there recipes or how-to for this cases?

@p69
Copy link
Owner

p69 commented Aug 15, 2019

Hi, could you please be more specific what would you like to achieve?
Do you want to update some widgets inside ProgramWidget? Or do you want to update specific ProgramWidget from the other widgets?

@ValeriusGC
Copy link
Author

ValeriusGC commented Aug 16, 2019

  • There are 2 screens, 2 models. And 2 db-tables backstage:
    • ActionScreen (AS), ActionModel (AM) with its messages, ActionTable (AT)
    • HistoryScreen (HS, HistoryModel (HM) with its messages, HistoryTable (HT)
    • Of course there are ProgramWidget on both of widgets, and DarteaMessagesBus on the root one
  • In the static situation screens keep their state between switching and this is OK
  • Changing Action* affects History* too, so both tables change and from AM i want send message or something to HM and HT about that
    But when HS is hidden no messages reach it from outer model AM and when i switch to it i see previous unchanged state

So, the question is: is there a solution within this library to transmit messages to hidden models?


BTW, just for information )))
Earlier i used to code for Android on Java/Kotline and use Moxy library. That library was keeping messages queue with a various behaviour and lifetime depending on some key.

@p69
Copy link
Owner

p69 commented Aug 20, 2019

Hey, sorry for long response.
Unfortunately it's not possible to do it in that way. Communication between ProgramWidgets is not possible if one of them is out of the tree.
I think you should reconsider your Model and Domain layer. Generally you shouldn't face such problems if you do it in a right way.
For example when you mutate your Actions model, I guess, you need to persist some data somehow. And when you show History screen you can read latest data from persistent storage.
It's not necessary to use persistent storage, it can be in memory data structure, but the idea is the same: update your data and initialize your widget with the latest changes.

I hope that helps. Any way you can ask anything if it's still unclear.

@ValeriusGC
Copy link
Author

ValeriusGC commented Aug 21, 2019

Hey, sorry for long response.
...
For example when you mutate your Actions model, I guess, you need to persist some data somehow. And when you show History screen you can read latest data from persistent storage.
It's not necessary to use persistent storage, it can be in memory data structure, but the idea is the same: update your data and initialize your widget with the latest changes.
...

Thanks for replying me.
Of course I could and of course i will it in this way or somehow.
But... The fact is it would be useful when View had information that something happened when it was offline. Since the Model has a long life cycle, so why not introduce the ability to store such information into it until the View appears again. I mean inside Dartea as part of kernel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants