Changeset 14654 for trunk/FACT++/scripts/doc
- Timestamp:
- 11/18/12 22:46:36 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/doc/Subscription.js
r14644 r14654 7 7 * @class 8 8 * 9 * Creates a handle to a new thread. The handle can be used to 10 * kill the thread or be ignored. The function provided is 11 * executed after an initial timeout. Note that although this 12 * looks similar to the setTimeout in web-browsers, after started, 13 * the thread will not run until completion but run in parallel to 14 * the executed script.<P> 9 * Subscription to a DIM service. 15 10 * 16 * Note that although the object is created with 'new' and there 17 * is a 'delete' is JavaScript, it will not call any kind of 18 * destructor. To close a Subscription you have to explicitly call 19 * the close() member function. 'delete' in JavaScript is only 20 * to remove a property from an Object. 11 * This class represents the subscription to a DIM service. Received 12 * events are first copied to an even queue internally, to avoid 13 * any processing blocking the DIM thread (which could block the 14 * whole network as a result). Then the events are processed. 15 * If a callback is installed, the processing will take place in 16 * another JavaScript thread. Physically it will run synchronously 17 * with the other JavaScript threads. However, the processing blocks 18 * event processing. Consequetly, processing should on average be 19 * faster than the frequency with which events arrive to ensure they 20 * will not fill up the memory and possible reactions to there 21 * contents will happen within a reasonable time and not delayed 22 * too much. 21 23 * 22 * @param { Integer} timeout23 * A positive integer given the initial delay in milliseconds before24 * the thread is executed.24 * @param {String} service 25 * Name of the DIM service to which a subscription should be made. 26 * Usully of the form SERVER/SUBSCRIPTION. 25 27 * 26 * @param {Function} function 27 * A function which is executed aftr the initial timeout. 28 * @param {Function} [callback] 29 * An optional function which is set as 'onchange' property. 30 * This can avoid to loose th first event after the subscription 31 * before the callback is set by the 'onchange' property (which 32 * is very unlikely). 28 33 * 29 34 * @throws 30 * <li> If number or type of arguments is wrong 35 * <li>If number or type of arguments is wrong 36 * <li>If an open subscription to the same service already exists. 31 37 * 32 38 * @example 33 * var handle = new Thread(100, function() { dim.out("Hello world!"); }); 34 * handle.kill(); 39 * var handle1 = new Subscription("MAGIC_WEATHER/DATA"); 40 * var handle2 = new Subscription("TNG_WEATHER/DATA", function(evt) { dim.out(JSON.stringify(evt)); }); 41 * ... 42 * handle2.close(); 43 * handle1.close(); 35 44 */ 36 function Subscription(service )45 function Subscription(service, callback) 37 46 { 38 47 /** … … 68 77 * 69 78 * @example 70 * subscription.onchange = function(event) { dim.out(JSON.stringify(event); };79 * handle.onchange = function(event) { dim.out(JSON.stringify(event); }; 71 80 * 72 81 */ 73 this.onchange = func;82 this.onchange = callback; 74 83 75 84 /**
Note:
See TracChangeset
for help on using the changeset viewer.