veilidchat/lib/init.dart
Christien Rioux 9bb20f4dd2 concurrency work in prep for speeding things up
refactor splash screen to process initialization in a better way
more async tools for async cubit constructors
greatly improved StateMapFollower class
2024-04-03 21:55:49 -04:00

46 lines
1.2 KiB
Dart

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:veilid_support/veilid_support.dart';
import 'account_manager/account_manager.dart';
import 'app.dart';
import 'tools/tools.dart';
import 'veilid_processor/veilid_processor.dart';
class VeilidChatGlobalInit {
VeilidChatGlobalInit._();
// Initialize Veilid
Future<void> _initializeVeilid() async {
// Init Veilid
Veilid.instance.initializeVeilidCore(
getDefaultVeilidPlatformConfig(kIsWeb, VeilidChatApp.name));
// Veilid logging
initVeilidLog(kDebugMode);
// Startup Veilid
await ProcessorRepository.instance.startup();
// DHT Record Pool
await DHTRecordPool.init();
}
// Initialize repositories
Future<void> _initializeRepositories() async {
await AccountRepository.instance.init();
}
static Future<VeilidChatGlobalInit> initialize() async {
final veilidChatGlobalInit = VeilidChatGlobalInit._();
log.info('Initializing Veilid');
await veilidChatGlobalInit._initializeVeilid();
log.info('Initializing Repositories');
await veilidChatGlobalInit._initializeRepositories();
return veilidChatGlobalInit;
}
}