Changeset 11380

Show
Ignore:
Timestamp:
11/04/07 10:07:03 (10 months ago)
Author:
alex
Message:

documentation updates. Refs #4820

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/AdapterRegistry.js

    r11339 r11380  
    22 
    33dojo.AdapterRegistry = function(/*Boolean?*/ returnWrappers){ 
    4         // summary: 
     4        //      summary: 
    55        //              A registry to make contextual calling/searching easier. 
    6         // description: 
     6        //      description: 
    77        //              Objects of this class keep list of arrays in the form [name, check, 
    88        //              wrap, directReturn] that are used to determine what the contextual 
    99        //              result of a set of checked arguments is. All check/wrap functions 
    1010        //              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 
    1132        this.pairs = []; 
    1233        this.returnWrappers = returnWrappers || false; // Boolean 
     
    1536dojo.extend(dojo.AdapterRegistry, { 
    1637        register: function(/*String*/ name, /*Function*/ check, /*Function*/ wrap, /*Boolean?*/ directReturn, /*Boolean?*/ override){ 
    17                 // summary:  
     38                //      summary:  
    1839                //              register a check function to determine if the wrap function or 
    1940                //              object gets selected 
    20                 // name: 
     41                //      name: 
    2142                //              a way to identify this matcher. 
    22                 // check: 
     43                //      check: 
    2344                //              a function that arguments are passed to from the adapter's 
    2445                //              match() function.  The check function should return true if the 
    2546                //              given arguments are appropriate for the wrap function. 
    26                 // directReturn: 
     47                //      directReturn: 
    2748                //              If directReturn is true, the value passed in for wrap will be 
    2849                //              returned instead of being called. Alternately, the 
     
    3152                //              the registry to act as a "search" function instead of a 
    3253                //              function interception library. 
    33                 // override: 
     54                //      override: 
    3455                //              If override is given and true, the check function will be given 
    3556                //              highest priority. Otherwise, it will be the lowest priority 
     
    3960 
    4061        match: function(/* ... */){ 
    41     // summary: 
     62                // summary: 
    4263                //              Find an adapter for the given arguments. If no suitable adapter 
    4364                //              is found, throws an exception. match() accepts any number of