Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessingChain, next method, handler param #16

Open
smart--petea opened this issue Sep 5, 2014 · 1 comment
Open

ProcessingChain, next method, handler param #16

smart--petea opened this issue Sep 5, 2014 · 1 comment

Comments

@smart--petea
Copy link
Contributor

in ProcesingChain.prototype.runChain the param with name handler is not used as function or object. The main meaning is to provide a name for filtering and search.
Maybe to replace it with the param named handlerName.
From the content of next function it result that there can be the situation when handlerName(or handler ) is undefined. This result from the snippet

if(handler) {
       var firstItem = self.findFirstValidItem(handler.name)
      ....
}

In this case, for handlerName=undefined (or handler=undefined) the snippet

for(var idx = currentItem + 1; idx < chain.length; idx++) {
     if(chain[idx.names&& chain[idx].names.indexOf(handler.name != -1 || !chain[idx].names) {
             break
      }
}

will be of nonsense.

In this case the function runChaid will become

ProcessingChain.prototype.runChain = function( req, res, finalFn, handler ) {
    ...
    var next = function(err) {
        ...
        if ( currentItem < totalItems - 1 ) {
                var idx = currentItem + 1;
                if(handlerName) {
                 for(; idx < chain.length; idx++) {
                     if( (chain[idx].names && chain[idx].names.indexOf(handlerName) != -1) || !chain[idx].names) {
                        break
                    }
               } 
                        } 
            ...
        } else {
            ...
        }
    }
    if(handlerName) {
        var firstItem = self.findFirstValidItem(handlerName)
               ...
    } else {
               ...
    }
};
@smart--petea
Copy link
Contributor Author

Maybe to advance the filtering by providing not a name but an array of names, e.g

ProcessingChain.prototype.runChain = function( req, res, finalFn, [name1, name2, name3] )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants