On Thu, Nov 18, 2010 at 07:12, omrihar <[email protected]> wrote:

>
> Hello All,
>
> I am using JSON-RPC (almost) exclusively to communicate with the server on
> an application I am writing.
> This application will be an internal one in my company, and will have
> probably at most 20 users working at once.
>
> I have read in the qooxdoo documentation that it is recommended to ALWAYS
> use Asynchronous calls to the RPC server, for many good reasons, but I am
> finding myself filling my application with many many many callback
> handlers,
> even when the logic of the program would require it to wait for the server
> response.
>
> So my question is this - under what circumstances is it permissible to use
> Synchronous calls to the server? Or is it really NEVER a good idea?
>

Hi, Omri. The strict answer to your question is "never" because in many
browsers, synchronous calls block the entire browser -- all tabs -- while
the synchronous call is awaiting a response. Rules, however, are meant to be
broken, when the reasons for doing so are carefully considered. :-)

That not withstanding, it does, in fact, take somewhat of a different mind
set to do good asynchronous programming than one would have working on
non-GUI applications. You do need to think differently, and design your
application on the assumption that events will occur when things of interest
to you, and otherwise, the browser's event loop is spinning and your program
is sitting idle. One very useful way of working in this type of environment
is to use a finite state machine. There will frequently be certain events
that you expect or want to handle at any one time, while other events should
be either queued for later, or ignored. The qx.util.Fsm.FiniteStateMachine
and associated qx.util.Fsm.* classes are really useful for handling this
sort of environment. With an application designed in such a way that
everything is event-driven, there should never be a need to use synchronous
RPCs.

Cheers,

Derrell
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to