Is your feature request related to a problem? Please describe.
In my app, I initialise Hive when a users logs in passing their user ID as the subDir where all Boxes should be stored. If a user logs out then logs back in (either as themselves or as a different user) I am unable to re-initialise Hive using the new ID as HiveImpl#init performs the following check
if (homePath != null) {
throw HiveError('Instance has already been initialized.');
}
Describe the solution you'd like
Perhaps a new method like Hive.updateHomePath(String newSubDir)? Or Hive.reinitialize(String subDir)?
Describe alternatives you've considered
For now I will need to manually add the users ID to the begining of every box path.
Version
hive: 2.0.0
hive_flutter: 1.0.0
I'd also like the feature to reinitialize Hive with a different path. I use Hive for caching and would like to be able to switch at runtime between a locally running server and a staging server.
Would a PR be accepted?
In Hive 1.* I could call Hive.init() multiple times and it worked:
See: #595
Hey @leisim , can you look at the issue? I think we have to allow changing homePath's value multiple times to not break exists use cases.
On latest version Hive now supports calling .init multiple times to update homePath
Most helpful comment
On latest version Hive now supports calling .init multiple times to update homePath