$initShared example

Could someone give me a quick explanation / code snippet for using $initShared in a projection?
I have checked the documentation, and had a quick Google but not found much.

I hoped it would created a shared state between many streams, but my testing suggests it’s not:

fromCategory(‘OrderAggregate’)
.foreachStream()
.when({
$initShared: function (s, e)
{
return {
count :0,
};
},

    $any : function(s,e){
        s.count++; //I was hoping only one count for all my OrderAggregate streams
    }
})

``

Thanks in advance.

Anyone???

I cannot find an example anywhere on how to use this.

Hi Steven,

If you can open an issue we will investigate that problem and we’ll add some specific documentation for $initShared

BTW I can see that there is a not required comma in your js (count :0,)

Thanks
Riccardo

Hi Riccardo,

I raised an issue here today:

Steven