using System;
namespace BCG
{
///
/// A more complete and 'correct' version of BlueRowCollectionStaticStream. Should replace it finally, though
/// at this time, to expedite the process, both exist simultaniously
///
public class MutableStream : ViewStream
{
public MutableStream () {}
public MutableStream (IBlueRowCollection rows)
{
loadCollection (rows);
}
///
/// Fires a datapacket with newRows set to the argument, and the whole previous state (if existed)
/// set as the deletedRows.
///
///
public void loadCollection (IBlueRowCollection rows)
{
myFireEvent(new DataPacket(
rows,
new BlueTable(rows),
myLastValue is DataPacket dp
? new BlueTable(dp.newRows)
: new BlueTable(rows.schema)));
}
///
/// Fires the whole datapacket as one. Its the callers responsibility to make sure that it makes incremental sense
///
///
public void loadPacket (DataPacket dp) {myFireEvent (dp);}
protected override void myOnFirstSubscriber()
{
if (myLastValue != null)
loadPacket (myLastValue as DataPacket);
}
}
}