Skip to content

Continuation Events

jmarnold edited this page Jul 7, 2012 · 3 revisions

Overview

Several events are useful to listen for during the processing of requests. The events are referred to as "topics" (ala amplifyjs):

AjaxStarted

Occurs whenever a new request is started. It has a correlationId property containing the ID of the request.

AjaxCompleted

Occurs whenever a request has completed. It has a correlationId property containing the ID of the request which can be used to correlate with the AjaxStarted event.

In order for the correlation process to work, your web framework must be made aware of the X-Correlation-Id header. This header is sent in the request and is expected to be in the response (in order to properly correlate).

ContinuationError

Occurs whenever a continuation is processed and the error property has a length greater than 0.

HttpError

Occurs whenever a continuation is processed and the status code is not 200.

How to consume the events

You can listen for any of the events using the bind method on the root continuations object:

$.continuations.bind('AjaxStarted', function(payload) { console.log(payload.correlationId); });

Note: You can also bind to '*' as a wildcard to listen for all events.

Relaying the events through amplify

There is an adapter available to relay all Continuation events through amplify. Simply include jquery.continuations.amplify.js