Closed vivainio closed 11 years ago
I agreed. Then when I started to remove the class, I realized we just need to document the purpose in using JSON as an asynchronously-updatable data model better. Update is below.
Ok, got it! So Task chain():ed after JSONGetter now get JSONObject is input parameter, right?
Yes. JSONModel is a parameter, it holds your current version of the JSONObject. This will automatgically be asynchronously be replaced by the JSONGetter. If you want to be "notified" when this happens, chain().
I don't really like static notifier pattern common in Java. Too rigid. In most cases, the code is much cleaner and most logical flow visible on one screen when you provide your own lambda expression each time you initiate an async operation.
Yep, but if I chain() a Task after JsonGetter, do I get JSONObject that was received as argument to doInBackground()?
You typically need the whole JSONObject, not the intermediate JSONModel.
JSONGetter should return JSONObject directly. There is no need to protect from multithreaded access since JSON objects coming over the network are typically used in immutable read-only fashion.