Git Product home page Git Product logo

Comments (6)

tunnckoCore avatar tunnckoCore commented on August 29, 2024

Just pass the wanted array to Promise.map. It's not needed to come from the task.

var files = ['foo', 'bar', 'baz']
taker.task('processAll', function(cb){
  Promise.map(files, function(file){
    return take.task('processFile', file)
  }).nodeify(cb);
});

what's the case, exactly?

from undertaker.

snowyu avatar snowyu commented on August 29, 2024

@tunnckoCore : It's just a sample to describe the scene. And for your question, this means the task 'processAll' can not be reused to another place. But it's an user's choose, you can do such thing.

from undertaker.

tunnckoCore avatar tunnckoCore commented on August 29, 2024

Hm. Okey, then you can bind it to function.

var files = ['foo', 'bar', 'baz']
function processAll () {
  return Promise.map(this.files, function(file){
    return take.task('processFile', file)
  })
}
taker.task('processAll', processAll.bind({files: files}));
taker.task('all', processAll.bind({files: files}));

In one or another side, it would always come from somewhere, so that "somewhere place" would be the place to bind the context.

from undertaker.

snowyu avatar snowyu commented on August 29, 2024

Please do not abuse the binding.

from undertaker.

phated avatar phated commented on August 29, 2024

All of these examples are confusing and incorrect. If you want to reuse a "task" just make a module that is the function and require it in each place. The taker.task API you keep referencing doesn't do magic things like call your function, it just returns one to you or registers on in the system.

from undertaker.

snowyu avatar snowyu commented on August 29, 2024

Ok, that's all right If the undertaker just serve the 'src()' only. But this is not enough as a general task manager. I've implemented the Folder object in the custom-file to collect the files in the folder. It provides another way to process for gulp4 except src If undertaker can support it.

Anyway, very thanks the great gulp4 processor. I think it is the best practice of KISS. The gulp4 is a "nothing" processor. So I think undertaker should be one too. It's a little pity.

from undertaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.