Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Pipeline

管线能执行任务达到某个效果

Hierarchy

  • Pipeline

Index

Constructors

Properties

Methods

Constructors

constructor

  • en

    Create a new pipeline

    zh

    创建一个管线

    example

    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(); } ]);

    Parameters

    • name: string

      The name of pipeline

    • funcs: IPipe[]

      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

    Returns Pipeline

Properties

id

id: number = Pipeline._pipelineId++

管线的 id

name

name: string = ""

管线的名字

pipes

pipes: IPipe[] = []

所有的管道

Static Private _pipelineId

_pipelineId: number = 0

Methods

Private flow

  • flow(index: number, task: Task): void

append

async

  • async(task: Task): void
  • 异步执行任务

    example

    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);

    Parameters

    • task: Task

      The task will be executed

    Returns void

insert

  • 在某个特定的点为管线插入一个新的 pipe

    example

    var pipeline = new Pipeline('test', []); pipeline.insert((task, done) => { // do something done(); }, 0);

    Parameters

    • func: IPipe

      The new pipe

    • index: number

      The specific point you want to insert at.

    Returns Pipeline

    pipeline

remove

  • 移除特定位置的管道

    example

    var pipeline = new Pipeline('test', (task, done) => { // do something done(); }); pipeline.remove(0);

    Parameters

    • index: number

      The specific point

    Returns Pipeline

    pipeline

sync

  • sync(task: Task): any
  • 同步执行任务

    example

    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));

    Parameters

    • task: Task

      The task will be executed

    Returns any

    result

Generated using TypeDoc