RxSwiftCommunity / RxRealm

RxSwift extension for RealmSwift's types
MIT License
1.15k stars 263 forks source link

Unhandled error happened: objectDeleted #120

Closed aiosDeveloper closed 5 years ago

aiosDeveloper commented 5 years ago

When I attempt to clean my db, this error was shown! "objectDeleted"

I use observer from this object in different place of my code.

this function in RXCocoa.swift call error: `// MARK: Shared with RxSwift

func rxFatalError(_ lastMessage: String) -> Never { // The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours. fatalError(lastMessage)

} `

this is my code: `func logout(){ //clean db DBManager.sharedInstance.deleteAllFromDatabase() }

func deleteAllFromDatabase() { try! database.write { database.deleteAll() print("Deleted All Profile objects") } } `

icanzilb commented 5 years ago

If you are observing an object that gets deleted you get ab error

aiosDeveloper commented 5 years ago

yes, thanks! but what we can do to solve this error? i need to observe an object and delete it when user loged out

freak4pc commented 5 years ago

Maybe just mark the record as logged out, get the update, and then delete it.

aiosDeveloper commented 5 years ago

how I can delete the record that was observe by UI objects?!

Observable.from(object: profileInDb) .map { profile -> UIImage in let avatar = self.imageStorageHandler.loadImageFromPath(profile.avatarDir) return avatar ?? #imageLiteral(resourceName: "test") } .bind(to: self.userImage.rx.image)

freak4pc commented 5 years ago

This repo's issues are more about technical issues with the library - I suggest to open a Stack Overflow question or post a question on RxSwift's slack: http://slack.rxswift.org