activateConfig function

Future<bool> activateConfig()

Activates what the last fetch brought back.

Answers false when there was nothing new, which is not a failure.

Implementation

Future<bool> activateConfig() {
  final completer = Completer<bool>();
  final receive = RawReceivePort();
  receive.handler = (Object? message) {
    receive.close();
    final parts = message! as List<Object?>;
    if (parts[0] == true) {
      completer.complete((parts[1]! as int) == 1);
    } else {
      completer.completeError(
        RemoteConfigException(
          parts[1]! as int,
          parts[2]! as String,
          'activate',
        ),
      );
    }
  };
  final rc = fdbRcActivate(receive.sendPort.nativePort);
  if (rc != 0) {
    receive.close();
    return Future.error(StateError('activate failed ($rc)'));
  }
  return completer.future;
}