Pipeline

Version: 9.0

Use the Pipeline component to set up JavaScript client-side pipelines and processors. SPEAK initializes and executes the processors according to your specifications.

You use the client-side pipelines to add processing without having to modify Sitecore core code.

A pipeline is a set of one or more steps that SPEAK executes in a specific order. Each step shares the same context. Each step can change the context and pass it to the next step until all steps have been completed (or the pipeline is aborted.) Each step can contain both client and server-side logic or just client-side logic.

Properties

Name

Description

LoadMode

Specify how SPEAK loads the pipeline:

  • Immediately: SPEAK loads the pipeline the same way as it loads other components. It loads all processor files in the initialize method of the Pipeline component.

  • Inline: SPEAK loads the pipeline when it loads the page, using inline scripting.

  • WhenRun: SPEAK loads the processor files when it executes the pipeline.

PipelineArgs

Specify the context of the pipeline.

PipelineItemId

Specify the ID of the Pipeline item that you use to configure the pipeline.

TargetControl and Trigger

Use these two properties to execute the pipeline based on an event triggered by a component on the page.

For example; specify TargetControl as Button1 and Trigger as click. SPEAK executes the pipeline when the user clicks the button that has Button1 as its ID.

Pipeline configuration

You configure the Pipeline component in this way:

  • Create a configuration item based on the Pipeline item template, and point the PipelineItemId property of the Pipeline component to this Pipeline item. You only need to specify the Name of the pipeline .

  • For each processor that you need, create an item based on the PipelineProcessor item template as a child item of the Pipeline item. The order of these items in the content tree is the order that SPEAK executes the processors in.

  • For each PipelineProcessor item, create a JavaScript file with the logic of the processor. Enter the path to the corresponding JavaScript file in the ProcessorFile fields of the PipelineProcessor items, and enter a name for the processor in the ProcessorName fields.

The JavaScript processors

The JavaScripts files where you implement the logic of the processors must always return a JavaScript object with the method "execute." For example:

RequestResponse
define(["sitecore"], function(Sitecore) { return { priority: 1, execute: function(context) { //my code    }  }define(["sitecore"], function (Sitecore) {  return {    priority: 1,    execute: function (context) {        //my code    }  }

You can abort the pipeline by assigning true to the context object passed to the execute method.

Using the pipeline

It can take some time for SPEAK to load a pipeline. Therefore, SPEAK provides an event that you can listen for, and this event tells when the pipeline is ready. Use the pipelineready event like this:

RequestResponse
this.MyPipeline.on("pipelineready", function(pipeline) { var context = { firstName: "John" };
    pipeline.execute(context); })this.MyPipeline.on("pipelineready", function (pipeline) {    var context = {        firstName: "John"    };    pipeline.execute( context );})

Do you have some feedback for us?

If you have suggestions for improving this article,