DEV Community

[Comment from a deleted post]
Collapse
 
ivan profile image
Ivan Dlugos

This started as a really nice roundup, though after looking at the main.dart example, I've been curious why you'd use those static "StoreHelpers".

I've had a look at the objectbox_example repo you've created in your github account and what you're doing is opening the store for every operation which is very inefficient. Besides, since you're never closing the store, it's also leaking memory on every call.

What were the reasons to go this approach, as opposed to keeping the store open during the app lifetime as in ObjectBox's example for Flutter?

Collapse
 
theimpulson profile image
Aayush Gupta

why you'd use those static "StoreHelpers"

Grouping data in a class that works on a similar object but as they don't depend upon each other they are static

What were the reasons to go this approach

The article is simply demonstrating how one can use the objectbox to work with a local persistent database. I do agree that I should have gone with a singleton pattern to create a Store instance or should have added a note for that. Just did now after seeing your comment.

Collapse
 
theimpulson profile image
Aayush Gupta

Ah, I get what you meant with static methods. Yeah, they don't need to be static considering the store and box variable is being repeatedly used, it can be moved to a class-level variable.