Projection issue filtering on Event Type

We have a small issue with a projection we are running, which should be filtering on specific Event Types:

fromAll()

.when({

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionSummaryAddedEvent’: processEvent,

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionLineAddedEvent’: processEvent,

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionStartedEvent’: processEvent

});

var processEvent = function (s, e) {

//Do some stuff

};

The Do some stuff never seems to get called.

If I then change the Projection to do this:

fromAll()

.when({

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionSummaryAddedEvent’: function (s, e) {

//Build the stream name from the Organisation Identifier

if (e.data) {

if (e.data.MetaData && e.data.MetaData.organisationId) {

var streamname = ‘AllSales_’ + e.data.MetaData.organisationId;

linkTo(streamname, e);

}

}

},

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionLineAddedEvent’: function (s, e) {

//Build the stream name from the Organisation Identifier

if (e.data) {

if (e.data.MetaData && e.data.MetaData.organisationId) {

var streamname = ‘AllSales_’ + e.data.MetaData.organisationId;

linkTo(streamname, e);

}

}

},

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionStartedEvent’: function (s, e) {

//Build the stream name from the Organisation Identifier

if (e.data) {

if (e.data.MetaData && e.data.MetaData.organisationId) {

var streamname = ‘AllSales_’ + e.data.MetaData.organisationId;

linkTo(streamname, e);

}

}

}

});

This works, but obviously is pretty nasty.

Have I missed something obvious on the first example?

Thanks in advance.

Steven

You need to declare the function before the actual projection itself.

i.e.

var processEvent = function (s, e) {

//Do some stuff

};

fromAll()

.when({

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionSummaryAddedEvent’: processEvent,

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionLineAddedEvent’: processEvent,

‘Tahoe.Eposity.SalesTransactions.DomainEvents.SalesTransactionStartedEvent’: processEvent

});

Thanks, that’s working fine now.