Pipeline Class

Module: cc

A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br> It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.</br> A list of items can flow in the pipeline and it will output the results of all pipes.</br> They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br> Finally all items will flow out the pipeline and the process is finished.

Index

Methods
  • constructor Constructor, pass an array of pipes to construct a new Pipeline, the pipes will be chained in the given order.</br> A pipe is an object which must contain an id in string and a handle function, the id must be unique in the pipeline.</br> It can also include async property to identify whether it's an asynchronous process.
  • insertPipe Insert a new pipe at the given index of the pipeline. </br> A pipe must contain an id in string and a handle function, the id must be unique in the pipeline.
  • insertPipeAfter !en Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. !zh 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。
  • appendPipe Add a new pipe at the end of the pipeline. </br> A pipe must contain an id in string and a handle function, the id must be unique in the pipeline.
  • flowIn Let new items flow into the pipeline. </br> Each item can be a simple url string or an object, if it's an object, it must contain id property. </br> You can specify its type by type property, by default, the type is the extension name in url. </br> By adding a skips property including pipe ids, you can skip these pipe. </br> The object can contain any supplementary property as you want. </br>
  • flowInDeps Let new items flow into the pipeline and give a callback when the list of items are all completed. </br> This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br> For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br> after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br> found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  • copyItemStates Copy the item states from one source item to all destination items. </br> It's quite useful when a pipe generate new items from one source item,</br> then you should flowIn these generated items into pipeline, </br> but you probably want them to skip all pipes the source item already go through,</br> you can achieve it with this API. </br> </br> For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  • isFlowing Returns whether the pipeline is flowing (contains item) currently.
  • getItems Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
  • getItem Returns an item in pipeline.
  • removeItem Removes an completed item in pipeline. It will only remove the cache in the pipeline or loader, its dependencies won't be released. cc.loader provided another method to completely cleanup the resource and its dependencies, please refer to cc.loader.release
  • clear Clear the current pipeline, this function will clean up the items.

Details

Methods

constructor

Constructor, pass an array of pipes to construct a new Pipeline, the pipes will be chained in the given order.</br> A pipe is an object which must contain an id in string and a handle function, the id must be unique in the pipeline.</br> It can also include async property to identify whether it's an asynchronous process.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:111
Parameters
Examples
var pipeline = new Pipeline([
     {
         id: 'Downloader',
         handle: function (item, callback) {},
         async: true
     },
     {id: 'Parser', handle: function (item) {}, async: false}
 ]);
insertPipe

Insert a new pipe at the given index of the pipeline. </br> A pipe must contain an id in string and a handle function, the id must be unique in the pipeline.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:155
Parameters
  • pipe Object The pipe to be inserted
  • index Number The index to insert
insertPipeAfter

!en Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. !zh 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:198
Parameters
  • refPipe Object An existing pipe in the pipeline.
  • newPipe Object The pipe to be inserted.
appendPipe

Add a new pipe at the end of the pipeline. </br> A pipe must contain an id in string and a handle function, the id must be unique in the pipeline.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:215
Parameters
  • pipe Object The pipe to be appended
flowIn

Let new items flow into the pipeline. </br> Each item can be a simple url string or an object, if it's an object, it must contain id property. </br> You can specify its type by type property, by default, the type is the extension name in url. </br> By adding a skips property including pipe ids, you can skip these pipe. </br> The object can contain any supplementary property as you want. </br>

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:239
Parameters
Examples
pipeline.flowIn([
     'res/Background.png',
     {
         id: 'res/scene.json',
         type: 'scene',
         name: 'scene',
         skips: ['Downloader']
     }
 ]);
flowInDeps

Let new items flow into the pipeline and give a callback when the list of items are all completed. </br> This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br> For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br> after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br> found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).

meta description
Returns Array
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:287
Deprecated since v1.3
Parameters
copyItemStates

Copy the item states from one source item to all destination items. </br> It's quite useful when a pipe generate new items from one source item,</br> then you should flowIn these generated items into pipeline, </br> but you probably want them to skip all pipes the source item already go through,</br> you can achieve it with this API. </br> </br> For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:324
Parameters
  • srcItem Object The source item
  • dstItems Array | Object A single destination item or an array of destination items
isFlowing

Returns whether the pipeline is flowing (contains item) currently.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:353
Deprecated since v1.3
getItems

Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.

meta description
Returns LoadingItems
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:364
Deprecated since v1.3
getItem

Returns an item in pipeline.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:375
Parameters
  • id Object The id of the item
removeItem

Removes an completed item in pipeline. It will only remove the cache in the pipeline or loader, its dependencies won't be released. cc.loader provided another method to completely cleanup the resource and its dependencies, please refer to cc.loader.release

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:395
Parameters
  • id Object The id of the item
clear

Clear the current pipeline, this function will clean up the items.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/load-pipeline/pipeline.js:415

results matching ""

    No results matching ""