reload method

Future<void> reload({
  1. bool force = false,
})

Fetch data using fromNetwork again. Immediately returns is isLocked is true.

If you set force to true then Data.value, Data.error is set to null and clearCache is called before calling fetch.

If your fromNetwork methods never ends (i.e. infinite stream), reload will also never finish. In that case do not await reload, or ensure your fromNetwork method finished (timeouts etc.).

Implementation

Future<void> reload({bool force = false}) async {
  if (isLocked) {
    return;
  }

  if (force) {
    await clearCache();
    _emit(const Data(isLoading: true));
  }

  await fetch();
}