systemDataFamily top-level property

AutoDisposeProviderFamily<AsyncValue<SystemData>, int> systemDataFamily
final

Provides Everon system data

If a Hub device is connected over BLE, system data from the Hub device will be returned. Otherwise, system data from the cloud backend will be returned.

Implementation

final systemDataFamily =
    Provider.autoDispose.family<AsyncValue<SystemData>, int>(
  (ref, int id) {
    final device = ref.watch(cachedDeviceFamily(id));
    final cloudData = ref.watch(cloudSystemDataFamily(id));

    if (device.hasValue) {
      final bleData =
          ref.watch(bleSystemDataFamily(device.valueOrNull!.serialNumber));

      if (bleData.hasValue) return bleData;
    }

    return cloudData;
  },
);