outputState method in Javascript projections

Hi,

In the javascript projections you have the outputState method to
indicate that the result of the projection should be output to a
stream. I have two questions concerning this:

* Is there a reason it is not chained after the 'when' method? When I
set the option manually it work correctly.
* Where is the state stored if it is not stored in a stream? I thought
everything in the EventStore was immutable. Or is it only stored in
memory?

Thanks for the info!

Tim Cools

Hi,

Your projection may only need to emit() events. In this case state is stored in memory and as a projection checkpoint from time to time.

Projection results is the most common way to output events from a projection. The outputState() method just makes the projection to assume "state is result"

Hi, thanks for the info.
so there is no reason why it is not available after the when()? Can
you (or I) add it? It would make my projections cleaner...

Thanks

see from 1Prelude:

    function when(handlers) {
        translateOn(handlers);
        return {
            $defines_state_transform: $defines_state_transform,
            transformBy: transformBy,
            filterBy: filterBy,
            ///outputState missing here
            outputTo: outputTo,
        };
    }

    function whenAny(handler) {
        eventProcessor.on_any(handler);
        return {
            $defines_state_transform: $defines_state_transform,
            transformBy: transformBy,
            filterBy: filterBy,
            outputState: outputState,
            outputTo: outputTo,
        };
    }

Yes, it should be there and you can safely add it.

Thank you, Yuriy