Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Pipeline

Pipeline can execute the task for some effect.

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++

The id of pipeline

name

name: string = ""

The name of pipeline

pipes

pipes: IPipe[] = []

All pipes of pipeline

Static Private _pipelineId

_pipelineId: number = 0

Methods

Private flow

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

append

async

  • async(task: Task): void
  • Execute task asynchronously

    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

  • At specific point insert a new pipe to pipeline

    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

  • Remove pipe which at specific point

    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
  • Execute task synchronously

    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