KoryNunn / kgo

A stupidly easy flow control function.
MIT License
18 stars 3 forks source link

Example using require() #5

Closed sholtomaud closed 10 years ago

sholtomaud commented 10 years ago

Hi

I'd like to use external library functions with kgo. Below is example pseudo code:

var utils = require('./utils.js');
var config = require('./config.json');
var utilName = 'thingy';

1. var utilSetup = utils.setup(utilName);
2. utils.config(config,utilSetup);

utils.config depends on the output of util.setup being available.

I've code something similar to below, but it doesn't pass utilSetup through correctly, so I'm not sure I've understood the concept.

Could you please provide an example using external library functions.

kgo
('setup', function(done){
   //Something async
   var utilSetup = utils.setup(utilName);
   done(null, utilSetup);
})
('run',['setup'],function(setup,done){
  var config = utils.config(config,setup);
  done(null, config);
})

Cheers

KoryNunn commented 10 years ago

For starters, it doesn't look like you are using async functions. Both utils.setup and utils.config seem to return a value, so there is no reason to use kgo.

If .setup() and config() take callbacks, then kgo is useful, and it would be coded like this:

kgo
('setup', function(done){
    utils.setup(utilName, done);
})
('run',['setup'],function(setup,done){
    utils.config(config, setup, done);
})
sholtomaud commented 10 years ago

Great thank you!

On Wed, Aug 20, 2014 at 11:02 AM, Kory Nunn notifications@github.com wrote:

Closed #5 https://github.com/KoryNunn/kgo/issues/5.

— Reply to this email directly or view it on GitHub https://github.com/KoryNunn/kgo/issues/5#event-154785914.

Mr Sholto Maud

m: +61 (0) 424 094 227

M.Eng. (Sys Eng) - RMIT Uni. Adv. Dip. (Comp Sci) - Swinburne Uni. B.A. (Env Sys) - Monash Uni.