Allow (optional) read-only access to Realm objects after deletion
Using Realm with reactive extensions, 3rd party libraries like DynamicData, and UI binding allows one to create beautifully dynamic, responsive apps with very few lines of clean code. This works fantastically for us in all scenarios except for when an item is deleted.
As we all know, currently any attempt to access an item's properties after deletion throws an exception. This throws a huge spanner in the works for various reactive operations and UI bindings, which may (for implementation detail purposes of object equality checks, UI redraws queued in the event loop queue, or a bunch of other possibilities) still briefly try to read the properties of an object after deletion. Even sometimes just to remove it from an internal cache somewhere along the reactive processing chain when processing the deletion itself.
As a result we have to constantly walk on eggshells in our code, put in lots of additional checks and filters and ugly hacks like flagging objects as deleted but not actually deleting them, or copying Realm object properties to keep them available, etc., just to try to avoid random app crashes that otherwise occur (since you can't catch these exceptions in any meaningful way when they occur in the middle of a reactive processing pipeline on the UI thread). And to date we have been far from totally successful.
All this code ugliness and app brittleness could be avoided if Realm object properties could still be read after detaching. It could be opt-in, either on a per-object basis (e.g. there could be an overridable 'AllowDetachedRead' property or similar) or at the Realm level as part of config.
Another way to offer this would be an optional 'AutoFreezeOnDetach' feature that automatically freezes the object in place when it is removed from the Realm. I tried doing this using existing functionality by calling FreezeInPlace() when the object becomes invalid, but that threw a native exception deep within the bowels of Realm. Not entirely surprised since by that point the object has already been deleted.
So, can we have an option like this please? It would make life so much simpler and cleaner.