openAsync static method
Opens a Hive event store with the given box names.
If the boxes already exist, they are reopened with existing data.
The boxName parameter is used as a prefix for the internal boxes.
Implementation
static Future<HiveEventStore> openAsync({required String boxName}) async {
final eventsBox = await Hive.openBox<String>('${boxName}_events');
final streamsBox = await Hive.openBox<int>('${boxName}_streams');
final transactionsBox = await Hive.openBox<String>('$boxName$_transactionsBoxSuffix');
await _recoverIncompleteTransactionsAsync(
eventsBox: eventsBox,
streamsBox: streamsBox,
transactionsBox: transactionsBox,
);
// Determine the current global sequence by finding the max
final globalSequence = eventsBox.isEmpty ? 0 : _findMaxGlobalSequence(eventsBox);
return HiveEventStore._(
eventsBox: eventsBox,
streamsBox: streamsBox,
transactionsBox: transactionsBox,
globalSequence: globalSequence,
);
}