Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

467
Vistas
Build compile errors in RxRealm.swift after RxRealm pod update: Type 'List<Element>' does not conform to protocol 'NotificationEmitter'

Here's the top portion of the file RxRealm.swift. (nowhere else in the file are there compile errors nor the "observe" func.

//
//  RxRealm extensions
//
//  Copyright (c) 2016 RxSwiftCommunity. All rights reserved.
//  Check the LICENSE file for details
//  Created by Marin Todorov
//

import Foundation
import RealmSwift
import RxSwift

public enum RxRealmError: Error {
  case objectDeleted
  case unknown
}

// MARK: Realm Collections type extensions

/**
 `NotificationEmitter` is a protocol to allow for Realm's collections to be handled in a generic way.

 All collections already include a `addNotificationBlock(_:)` method - making them conform to `NotificationEmitter` just makes it easier to add Rx methods to them.

 The methods of essence in this protocol are `asObservable(...)`, which allow for observing for changes on Realm's collections.
 */
public protocol NotificationEmitter {
  associatedtype ElementType: RealmCollectionValue

  /**
   Returns a `NotificationToken`, which while retained enables change notifications for the current collection.

   - returns: `NotificationToken` - retain this value to keep notifications being emitted for the current collection.
   */
  func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<Self>) -> Void) -> NotificationToken

  func toArray() -> [ElementType]

  func toAnyCollection() -> AnyRealmCollection<ElementType>
}

extension List: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<Element>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

extension AnyRealmCollection: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<ElementType>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

extension Results: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<ElementType>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

extension LinkingObjects: NotificationEmitter {
  public func toAnyCollection() -> AnyRealmCollection<Element> {
    return AnyRealmCollection<ElementType>(self)
  }

  public typealias ElementType = Element
  public func toArray() -> [Element] {
    return Array(self)
  }
}

I've tried adding the protocol stubs as suggested but I don't know what goes inside the added observe function.

public func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<List<Element>>) -> Void) -> NotificationToken {
        // what goes here? 
    }

I've tried leaving the function blank but it spits out another error: "Missing return in a function expected to return 'NotificationToken' (aka 'RLMNotificationToken')"

If I put in a return function I have no idea what to put in there. Obv it's the NotificiationToken type, but now I'm lost.

This is really above my head, but there's nothing about it on Cocoapods https://cocoapods.org/pods/RxRealm

Any ideas how to fix this?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

working for me:

pod 'Realm', '10.20.1'  
pod 'RealmSwift', '10.20.1'  
pod 'RxRealm', '4.0.3'
over 4 years ago · Santiago Trujillo Denunciar

0

In Xcode 13.2.1, you can add this method, from xcode suggestion extension of List, Results...

public func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<List<Element>>) -> Void) -> NotificationToken {
        // what goes here? 
    }

--->

public func observe(on queue: DispatchQueue?, _ block: @escaping (RealmCollectionChange<Results<Element>>) -> Void) -> NotificationToken {
        return self.observe(keyPaths: nil, on: queue, block)
    }

Your problem will be resolve, but if you using Cocoapods, you must directly edit RXRealm file in your pods.

over 4 years ago · Santiago Trujillo Denunciar

0

working config.

  pod 'RxSwift', '~> 5'
  pod 'RxCocoa', '~> 5'
  pod 'RxAlamofire', '~> 5.1.0'
  pod 'RxRealm'
  pod 'RealmSwift', '10.20.1'
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda