Answer the question
In order to leave comments, you need to log in
How to correctly change the state of an object on previous screens?
There is an application similar in functionality to twitter.
There is a feed from which you can go to a user or a tweet, users can have tweet feeds that you can also go to, from a tweet you can go to a user, and so on. In theory, nesting can be very long.
There is navigation back so I can go back to previous screens.
But if at some point I like a tweet. I change its state, I have to throw it to the previous screen, and from the previous one to the previous one, and so on. But you can forget to skip on some screen and if you meet a tweet that I already liked, its state will be incorrect.
How to do it right?
Answer the question
In order to leave comments, you need to log in
To do this, you need to write an application architecturally supporting such functionality.
- either send notifications by the service and listen with all windows
- either subscribe to model changes through reactivity
- or connect screens with services with callbacks
Even Facebook did not solve this problem)
Seriously, the only reliable way to solve it is to write any change to the server (or to a local database, or to a global variable) and re-read possible changes on any transition between screens before drawing the screen.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question