Giter Club home page Giter Club logo

Comments (4)

paulirotta avatar paulirotta commented on June 30, 2024

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.

  • The point of JSONModel is, like XMLModel, to allow you to create a local Object of type
  • JSONModel which may last the entire life of your application. You can then
  • refer to values from JSONModel and know that it always contains the latest,
  • best JSONObject received from the server or loaded from the local cache.
  • You can update the value in JSONModel by passing it as an object when you
  • call JSONGetter(url, myJSONMOdel). If you would like to execute some code such
  • as updating the user interface after the JSONModel is updated asynchonously,
  • you should chain() that continuation code (a Task or UITask) to the JSONGetter.

from tantalum.

vivainio avatar vivainio commented on June 30, 2024

Ok, got it! So Task chain():ed after JSONGetter now get JSONObject is input parameter, right?

from tantalum.

paulirotta avatar paulirotta commented on June 30, 2024

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.

from tantalum.

vivainio avatar vivainio commented on June 30, 2024

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.

from tantalum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.