Evaluate how to best scope delete method on RealmObject interface

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Currently we have RealmObject.delete() as an extension method. This allows for a nice shorthand when writing

      realm.writeBlocking {
        val john = copyToRealm(Person())
        john.delete()
      }
      

      Unfortunately, this is also possible outside the write transaction

      val john = Person()
      john.delete() // Will throw an exception
      

      We should evaluate if the fluency of the API trumps making it slightly less safe or if we can find a better way to control the scope of the delete method.

      We already expose a delete method on the MutableRealm, so you can do something like this:

      realm.writeBlocking {
        val john = copyToRealm(Person())
        delete(john)
      }
      

            Assignee:
            Claus Rørbech (Inactive)
            Reporter:
            Unito Sync Bot
            Archiver:
            Marc Greenfield

              Created:
              Updated:
              Resolved:
              Archived: