             }
         }
 
-        var updates: [Update] = []
+        var updates: [ArrayUpdate] = []
         if !replacements.isEmpty {
-            updates.append(Update(.replace, replacements))
+            updates.append(ArrayUpdate(.replace, replacements))
         }
         if !insertions.isEmpty {
-            updates.append(Update(.insert, insertions))
+            updates.append(ArrayUpdate(.insert, insertions))
         }
         if !deletions.isEmpty {
-            updates.append(Update(.delete, deletions))
+            updates.append(ArrayUpdate(.delete, deletions))
         }
 
         value = new

        let oldCount = value.count
        value.insert(contentsOf: newElements, at: i)
        let insertedCount = value.count - oldCount
        updates.send([Update(.insert, Array(i..<i + insertedCount))])
    }

    public func append(_ newElement: T) {
        value.append(newElement)
        updates.send([Update(.insert, [value.count - 1])])
    }

    public func append<S>(contentsOf newElements: S) where S : Sequence, T == S.Element {
        let end = value.count
        value.append(contentsOf: newElements)
        guard end != value.count else { return }
        updates.send([Update(.insert, Array(end..<value.count))])
    }

    // Deletions
    public func removeLast() -> Element {
        let element = value.removeLast()
        updates.send([Update(.delete, [value.count])])
        return element
    }

    @discardableResult
    public func remove(at position: Int) -> Element {
        let element = value.remove(at: position)
        updates.send([Update(.delete, [position])])
        return element
    }


    }
}

public struct ArrayUpdate {
    public enum Event {
        case insert
        case delete
        case replace
    }
    
    public let event: Event
    public let indexes: [Int]
    
    public init(_ type: Event,
                _ indexes: [Int]) {
        self.event = type
        self.indexes = indexes
    }
}

public final class ObservableArray<T: Equatable>: ObservableValueHolder<[T]>, Collection, MutableCollection, CustomStringConvertible, CustomDebugStringConvertible, ExpressibleByArrayLiteral, RangeReplaceableCollection {

    public typealias Element = T

    public let updates = Signal<[ArrayUpdate]>()

    public init() {
        super.init([])
