coa icon indicating copy to clipboard operation
coa copied to clipboard

Change interface of .act() callback functions

Open arikon opened this issue 10 years ago • 3 comments

My proposal it to change API of .act() callbacks from

function(opts, args) {
}

to

function(options) {
   // options = opts + args
}

Motivation

  1. The difference between opts and args in semantical only and only make sense when command is run from the command line

  2. It is hard to explain to develepor what the difference between opts and args when it uses COA API to run command

  3. Division into two different arguments makes sense in case when opts is a hash and args is an array

  4. Compare

    var BEM = require('bem');
    BEM.api.create.block({ tech: ['css', 'js'] }, { names: ['b1', 'b2'] });
    

    and

    var BEM = require('bem');
    BEM.api.create.block({ names: ['b1', 'b2'], tech: ['css', 'js'] });
    

/cc @veged

arikon avatar Jul 19 '13 08:07 arikon

we can just add args to opts but keep second argument for act function for full backward compatibility

veged avatar Jul 19 '13 09:07 veged

@veged Backwards compatibility will broke if there were args and opts with the same name('...') declaration

arikon avatar Jul 19 '13 09:07 arikon

@arikon yep, but that's some kind "unsemantic" and seems nobody do that

veged avatar Jul 20 '13 20:07 veged