On Tuesday, July 15, 2003, at 05:43 PM, Christopher Oliver wrote:


Jeremy Quinn wrote:


On Tuesday, July 15, 2003, at 02:19 PM, Vadim Gritsenko wrote:



<snip/>



While I do actually use Continuations in some functions, I strenuously avoid keeping any other 'app state' in Global variables, so that the user can have multiple browser windows open with different independent tasks in progress in each one.

Not sure what you mean here. Using JS global variables makes it very easy to share state between page flows, for example in the Petstore the same Cart object is shared between various page flows:


- addToCart
- removeItemFromCart
- updateCart
- showCart
- checkout

In the Petstore app, it makes sense to only allow one instance of the store per user, so if they open another window they are still editing the same store. So in your case it makes sense to have the petstore as a global (HTTP Session) variable.


In my application, I want people to be able to work on different parts of the application at the same time, independently of each other. In one window they may be working on 'Coverage' in another window they may be working on 'People', this is a design decision. Therefore in my case I must not keep 'the thing being edited' in a global variable. My externally invoked functions therefore always take an ID and TYPE parameter, so that this specific object can be retrieved for each function call. It is only when I have a Continuation that the specific Object is held in a variable, and then it is always a local one.

Conversely, the logged in User object must be shared by all invocations, so this is a global.

Hope this is clearer.

regards Jeremy



Reply via email to