管线能执行任务达到某个效果
Create a new pipeline
创建一个管线
var pipeline = new Pipeline('download', [ (task, done) => { var url = task.input; cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { task.output = result; done(err); }); }, (task, done) => { var text = task.input; var json = JSON.stringify(text); task.output = json; done(); } ]);
The name of pipeline
The array of pipe, every pipe must be function which take two parameters, the first is a Task flowed in pipeline, the second is complete callback
Task
管线的 id
管线的名字
所有的管道
添加一个管道到管线中
var pipeline = new Pipeline('test', []); pipeline.append((task, done) => { // do something done(); });
The new pipe
pipeline
异步执行任务
var pipeline = new Pipeline('sync', [(task, done) => { let input = task.input; task.output = doSomething(task.input); done(); }]); var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); pipeline.async(task);
The task will be executed
在某个特定的点为管线插入一个新的 pipe
var pipeline = new Pipeline('test', []); pipeline.insert((task, done) => { // do something done(); }, 0);
The specific point you want to insert at.
移除特定位置的管道
var pipeline = new Pipeline('test', (task, done) => { // do something done(); }); pipeline.remove(0);
The specific point
同步执行任务
var pipeline = new Pipeline('sync', [(task) => { let input = task.input; task.output = doSomething(task.input); }]); var task = new Task({input: 'test'}); console.log(pipeline.sync(task));
result
Generated using TypeDoc
管线能执行任务达到某个效果