W3C home > Mailing lists > Public > www-svg@w3.org > March 2004

Sync. network operation and JavaScript's lack of having modules

From: Jan-Klaas Kollhof <keyjaque@yahoo.com>
Date: Wed, 17 Mar 2004 01:58:17 -0800 (PST)
Message-ID: <20040317095817.10913.qmail@web60104.mail.yahoo.com>
To: www-svg@w3.org

Hello,

I have mentioned this a fiew times.
I would like to have sync. network operation.
I have heard the concers about UA blocking.
But they have yet not convinsed me :).

One thing I need sync network for is to dynamically
load javascript. This allows a more modularized
development.
JavaScript does not have packages or
modules(JavaScript 2 will maybe!!!)
If it would it would need sync network underneath to
load them when required.

here an example:

if(condition){
   //do something
}else{
   var logger = importModule("logger");
   logger.append("there was an unusual error");
}
//more code

The logger.js is only loaded if the condition is
false.
otherwise the code is never loaded.
This works nicely in IE and Moz just not in SVG.
Yes this could be rewritten to use async connections
using callbacks:

if(condition){
  //do something
}else{
   importModule("logger", function(logger){
       logger.append("there was a prob");
   })
}
//more code now executed before logger :(

This is not pretty(in more than one way).

A whole module that imports ohters would look like:

m1 = importModule("m1")
m2 = importModule("m2")
//module code

and for async:
importModule("m1" function(m1){
importModule("m1" function(m2){
     //module code here
})
})

the async approch does not work all the time though

I am getting around this problem by just referencing
all scripts that MIGHT be used in my SVG.

Another reason is RPC. Sometimes I would like to be
able to do sync rpc calls. 


Jan
 

__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
Received on Wednesday, 17 March 2004 04:58:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 5 November 2012 23:52:55 GMT