objectbox-dart
objectbox-dart copied to clipboard
Lazy loading wrapper
We could provide a Lazy<T> wrapper to improve loading large data. It could work similarly to ToOne relation wrapper, with value getter loading the content on-demand.
@Entity
TestEntity {
int id;
// current, non-lazy property
String largeString;
// suggested, lazy-loading wrapper
Lazy<String> lazilyLoadedLargeString;
}
Not sure about storage though... With the current native API, we can't serialize partial object data (when .value wasn't set if the object is put()). The workaround would be to read the whole object before putting copy the binary data of the existing value without converting from & back to flatbuffers.
On the other hand, a similar thing can be achieved with ToOne already, it just means you have to an additional entity. However, that could actually also be the solution, with Lazy<> defining a non-accessible 1-to-1 relation ... there are many options and this isn't a priority at the moment (unless there's strong demand)
I got crash when I save large String (~70k length). Is Lazy String available right now
No, not available and not in the works at the moment.
The crash you're referring to has been recently fixed by e259aea9d8c476c020afa46f67f2b970fd235088 which will come out in a next release next week.
@vaind thank you