MangadexClient constructor

MangadexClient({
  1. bool autoRefresh = true,
  2. Duration? refreshDuration,
  3. void onRefresh()?,
})

Implementation

MangadexClient(
    {this.autoRefresh = true,
    this.refreshDuration,
    // this.autoSave = false,
    // this.saveDirectory,
    // this.filename,
    this.onRefresh}) {
  // if (saveDirectory != null && filename != null && autoSave != false) {
  //   loadFromLocation(saveDirectory!, filename)
  //       .then((value) => _token = value);
  // }
  _refreshTimer =
      Timer.periodic(refreshDuration ?? Duration(minutes: 14), (timer) async {
    if (_token != null) {
      try {
        _token = (await AuthRepository.refresh(_token!.refreshToken));
        if (onRefresh != null) {
          onRefresh!();
        }
      } on Exception {
        _token = null;
      }
    }
  });
}