Changeset 11380
- Timestamp:
- 11/04/07 10:07:03 (10 months ago)
- Files:
-
- 1 modified
-
dojo/trunk/AdapterRegistry.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/AdapterRegistry.js
r11339 r11380 2 2 3 3 dojo.AdapterRegistry = function(/*Boolean?*/ returnWrappers){ 4 // summary:4 // summary: 5 5 // A registry to make contextual calling/searching easier. 6 // description:6 // description: 7 7 // Objects of this class keep list of arrays in the form [name, check, 8 8 // wrap, directReturn] that are used to determine what the contextual 9 9 // result of a set of checked arguments is. All check/wrap functions 10 10 // in this registry should be of the same arity. 11 // example: 12 // | // create a new registry 13 // | var reg = new dojo.AdapterRegistry(); 14 // | reg.register("handleString", 15 // | dojo.isString, 16 // | function(str){ 17 // | // do something with the string here 18 // | } 19 // | ); 20 // | reg.register("handleArr", 21 // | dojo.isArray, 22 // | function(arr){ 23 // | // do something with the array here 24 // | } 25 // | ); 26 // | 27 // | // now we can pass reg.match() *either* an array or a string and 28 // | // the value we pass will get handled by the right function 29 // | reg.match("someValue"); // will call the first function 30 // | reg.match(["someValue"]); // will call the second 31 11 32 this.pairs = []; 12 33 this.returnWrappers = returnWrappers || false; // Boolean … … 15 36 dojo.extend(dojo.AdapterRegistry, { 16 37 register: function(/*String*/ name, /*Function*/ check, /*Function*/ wrap, /*Boolean?*/ directReturn, /*Boolean?*/ override){ 17 // summary:38 // summary: 18 39 // register a check function to determine if the wrap function or 19 40 // object gets selected 20 // name:41 // name: 21 42 // a way to identify this matcher. 22 // check:43 // check: 23 44 // a function that arguments are passed to from the adapter's 24 45 // match() function. The check function should return true if the 25 46 // given arguments are appropriate for the wrap function. 26 // directReturn:47 // directReturn: 27 48 // If directReturn is true, the value passed in for wrap will be 28 49 // returned instead of being called. Alternately, the … … 31 52 // the registry to act as a "search" function instead of a 32 53 // function interception library. 33 // override:54 // override: 34 55 // If override is given and true, the check function will be given 35 56 // highest priority. Otherwise, it will be the lowest priority … … 39 60 40 61 match: function(/* ... */){ 41 // summary:62 // summary: 42 63 // Find an adapter for the given arguments. If no suitable adapter 43 64 // is found, throws an exception. match() accepts any number of