Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

463
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda