initialize method

Future<void> initialize()

Initializes the manager and its adapters. Must be called before any other methods.

Implementation

Future<void> initialize() async {
  if (_initialized) return;
  ensureNotDisposed();

  await localAdapter.initialize();
  await _runSchemaMigrations();
  await _isolateHelper.initialize();
  await remoteAdapter.initialize();

  _initialized = true;
  _logger.info('DatumManager for $T initialized.');

  // Start auto-sync after the manager is fully initialized.
  await _setupAutoSyncIfEnabled();

  // Subscribe to external changes
  _subscribeToChangeStreams();

  // Subscribe to internal events to notify observers
  // _listenToEvents(); // This is now handled synchronously in synchronize()
}