@@ -28,6 +28,9 @@ public enum CombineRealmError: Error {
2828public protocol NotificationEmitter {
2929 associatedtype ElementType : RealmCollectionValue
3030
31+ func observe( on queue: DispatchQueue ? ,
32+ _ block: @escaping ( RealmCollectionChange < Self > ) -> Void )
33+ -> NotificationToken
3134 /**
3235 Returns a `NotificationToken`, which while retained enables change notifications for the current collection.
3336
@@ -40,6 +43,12 @@ public protocol NotificationEmitter {
4043 func toAnyCollection( ) -> AnyRealmCollection < ElementType >
4144}
4245
46+ extension NotificationEmitter {
47+ public func observe( _ block: @escaping ( RealmCollectionChange < Self > ) -> Void ) -> NotificationToken {
48+ self . observe ( on: nil , block)
49+ }
50+ }
51+
4352extension List : NotificationEmitter {
4453 public func toAnyCollection( ) -> AnyRealmCollection < Element > {
4554 return AnyRealmCollection < Element > ( self )
@@ -163,7 +172,7 @@ public enum RealmPublishers {
163172 public static func collection< Output: NotificationEmitter > ( from collection: Output ,
164173 synchronousStart: Bool = true )
165174 -> AnyPublisher < Output , Error > {
166-
175+
167176 let initialValue : Output ? = synchronousStart ? collection : nil
168177 return RealmPublisher < Output , Error > ( initialValue: initialValue) { subscriber in
169178 return collection. observe { changeset in
@@ -304,8 +313,8 @@ public enum RealmPublishers {
304313 return RealmPublisher < O , Error > ( initialValue: initialValue) { subscriber in
305314 return object. observe { change in
306315 switch change {
307- case let . change( changedProperties) :
308- if let properties = properties, !changedProperties. contains { return properties. contains ( $0. name) } {
316+ case let . change( _ , changedProperties) :
317+ if let properties = properties, !changedProperties. contains ( where : { return properties. contains ( $0. name) } ) {
309318 // if change property isn't an observed one, just return
310319 return
311320 }
@@ -332,7 +341,7 @@ public enum RealmPublishers {
332341 return RealmPublisher < PropertyChange , Error > { subscriber in
333342 return object. observe { change in
334343 switch change {
335- case let . change( changes) :
344+ case let . change( _ , changes) :
336345 for change in changes {
337346 _ = subscriber. receive ( change)
338347 }
0 commit comments