New: Entire source code with tests is now at <https://github.com/bboyle1234/ReactiveTest>

Let's imagine we have a view state object that is able to be updated by small partial view change events. Here are some example models of the total view, the incremental view update events and the accumulator function `Update` that builds the total view: 

```cs
interface IDeviceView : ICloneable {
    Guid DeviceId { get; }
}

class DeviceTotalView : IDeviceView {
    public Guid DeviceId { get; set; }
    public int Voltage { get; set; }
    public int Currents { get; set; }
    public object Clone() => this.MemberwiseClone();
}

class DeviceVoltagesUpdateView : IDeviceView {
    public Guid DeviceId { get; set; }
    public int Voltage { get; set; }
    public object Clone() => this.MemberwiseClone();
}

class DeviceCurrentsUpdateView : IDeviceView {
    public Guid DeviceId { get; set; }
    public int Current { get; set; }
    public object Clone() => this.MemberwiseClone();
}

class DeviceUpdateEvent {
    public DeviceTotalView View;
    public IDeviceView LastUpdate;
}

static DeviceUpdateEvent Update(DeviceUpdateEvent previousUpdate, IDeviceView update) {
    if (update.DeviceId != previousUpdate.View.DeviceId) throw new InvalidOperationException("Device ids do not match (numskull exception).");
    var view = (DeviceTotalView)previousUpdate.View.Clone();
    switch (update) {
        case DeviceVoltagesUpdateView x: {
            view.Voltage = x.Voltage;
            break;
        }
        case DeviceCurrentsUpdateView x: {
            view.Currents = x.Current;
            break;
        }
    }
    return new DeviceUpdateEvent { View = view, LastUpdate = update };
}

```

Next, let's imagine we already have an injectable service that is able to produce an observable stream of the small update events for all devices, and that we want to create a service that can produce an aggregated view stream for individual devices.

Here is the interface of the service we want to create: 

```cs
interface IDeviceService {
    /// <summary>
    /// Gets an observable that produces aggregated update events for the device with the given deviceId.
    /// On subscription, the most recent event is immediately pushed to the subscriber.
    /// There can be multiple subscribers.
    /// </summary>
    IObservable<DeviceUpdateEvent> GetDeviceStream(Guid deviceId);
}

```

How can I implement this interface and its requirements using the reactive extensions in the `System.Reactive v4` library, targeting `.netstandard2.0`? Here's my boiler code with comments and that's as far as I've been able to get.

```cs
class DeviceService : IDeviceService {

    readonly IObservable<IDeviceView> Source;

    public DeviceService(IObservable<IDeviceView> source) { // injected parameter
        /// When injected here, "source" is cold in the sense that it won't produce events until the first time it is subscribed.
        /// "source" will throw an exception if its "Subscribe" method is called more than once as it is intended to have only one observer and 
        /// be read all the way from the beginning.
        Source = source;

        /// Callers of the "Subscribe" method below will expect data to be preloaded and will expect to be immediately delivered the most
        /// recent event. So we need to immediately subscribe to "source" and start preloading the aggregate streams.

        /// I'm assuming there is going to need to be a groupby to split the stream by device id.
        var groups = source.GroupBy(x => x.DeviceId);
        /// Now somehow we need to perform the aggregrate function on each grouping.
        /// And create an observable that immediately delivers the most recent aggregated event when "Subscribe" is called below.
    }

    public IObservable<DeviceUpdateEvent> GetDeviceStream(Guid deviceId) {
        /// How do we implement this? The observable that we return must be pre-loaded with the latest update
        throw new NotImplementedException();
    }
}

```